From 5b0060bef164b4522177ffd8fba0c408e8b2324b Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 9 Aug 2022 19:03:16 -0700 Subject: [PATCH] code and test (#25616) Co-authored-by: PythonSdkPipelines --- sdk/storage/azure-mgmt-storage/CHANGELOG.md | 7 + sdk/storage/azure-mgmt-storage/MANIFEST.in | 2 +- sdk/storage/azure-mgmt-storage/README.md | 2 +- sdk/storage/azure-mgmt-storage/_meta.json | 6 +- .../storage/_storage_management_client.py | 69 +- .../azure/mgmt/storage/_version.py | 2 +- .../storage/aio/_storage_management_client.py | 69 +- .../azure/mgmt/storage/models.py | 2 +- .../mgmt/storage/v2015_06_15/__init__.py | 13 +- .../storage/v2015_06_15/_configuration.py | 12 +- .../mgmt/storage/v2015_06_15/_metadata.json | 4 +- .../v2015_06_15/_storage_management.py | 20 +- .../mgmt/storage/v2015_06_15/_version.py | 2 +- .../mgmt/storage/v2015_06_15/aio/__init__.py | 13 +- .../storage/v2015_06_15/aio/_configuration.py | 12 +- .../v2015_06_15/aio/_storage_management.py | 18 +- .../v2015_06_15/aio/operations/__init__.py | 5 + .../v2015_06_15/aio/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 324 +- .../aio/operations/_usage_operations.py | 64 +- .../storage/v2015_06_15/models/__init__.py | 6 +- .../storage/v2015_06_15/models/_models_py3.py | 78 +- .../mgmt/storage/v2015_06_15/models/_patch.py | 19 + .../models/_storage_management_enums.py | 11 +- .../v2015_06_15/operations/__init__.py | 5 + .../storage/v2015_06_15/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 557 +- .../operations/_usage_operations.py | 92 +- .../mgmt/storage/v2016_01_01/__init__.py | 13 +- .../storage/v2016_01_01/_configuration.py | 12 +- .../mgmt/storage/v2016_01_01/_metadata.json | 4 +- .../v2016_01_01/_storage_management_client.py | 20 +- .../mgmt/storage/v2016_01_01/_version.py | 2 +- .../mgmt/storage/v2016_01_01/aio/__init__.py | 13 +- .../storage/v2016_01_01/aio/_configuration.py | 12 +- .../aio/_storage_management_client.py | 18 +- .../v2016_01_01/aio/operations/__init__.py | 5 + .../v2016_01_01/aio/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 324 +- .../aio/operations/_usage_operations.py | 64 +- .../storage/v2016_01_01/models/__init__.py | 6 +- .../storage/v2016_01_01/models/_models_py3.py | 72 +- .../mgmt/storage/v2016_01_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 19 +- .../v2016_01_01/operations/__init__.py | 5 + .../storage/v2016_01_01/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 557 +- .../operations/_usage_operations.py | 92 +- .../mgmt/storage/v2016_12_01/__init__.py | 13 +- .../storage/v2016_12_01/_configuration.py | 12 +- .../mgmt/storage/v2016_12_01/_metadata.json | 4 +- .../v2016_12_01/_storage_management.py | 20 +- .../mgmt/storage/v2016_12_01/_version.py | 2 +- .../mgmt/storage/v2016_12_01/aio/__init__.py | 13 +- .../storage/v2016_12_01/aio/_configuration.py | 12 +- .../v2016_12_01/aio/_storage_management.py | 18 +- .../v2016_12_01/aio/operations/__init__.py | 5 + .../v2016_12_01/aio/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 361 +- .../aio/operations/_usage_operations.py | 64 +- .../storage/v2016_12_01/models/__init__.py | 6 +- .../storage/v2016_12_01/models/_models_py3.py | 132 +- .../mgmt/storage/v2016_12_01/models/_patch.py | 19 + .../models/_storage_management_enums.py | 31 +- .../v2016_12_01/operations/__init__.py | 5 + .../storage/v2016_12_01/operations/_patch.py | 19 + .../_storage_accounts_operations.py | 652 +- .../operations/_usage_operations.py | 92 +- .../mgmt/storage/v2017_06_01/__init__.py | 13 +- .../storage/v2017_06_01/_configuration.py | 12 +- .../mgmt/storage/v2017_06_01/_metadata.json | 4 +- .../v2017_06_01/_storage_management.py | 28 +- .../mgmt/storage/v2017_06_01/_version.py | 2 +- .../mgmt/storage/v2017_06_01/aio/__init__.py | 13 +- .../storage/v2017_06_01/aio/_configuration.py | 12 +- .../v2017_06_01/aio/_storage_management.py | 26 +- .../v2017_06_01/aio/operations/__init__.py | 5 + .../v2017_06_01/aio/operations/_operations.py | 64 +- .../v2017_06_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 361 +- .../aio/operations/_usage_operations.py | 64 +- .../storage/v2017_06_01/models/__init__.py | 6 +- .../storage/v2017_06_01/models/_models_py3.py | 199 +- .../mgmt/storage/v2017_06_01/models/_patch.py | 19 + .../models/_storage_management_enums.py | 39 +- .../v2017_06_01/operations/__init__.py | 5 + .../v2017_06_01/operations/_operations.py | 90 +- .../storage/v2017_06_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 652 +- .../operations/_usage_operations.py | 92 +- .../mgmt/storage/v2017_10_01/__init__.py | 13 +- .../storage/v2017_10_01/_configuration.py | 12 +- .../mgmt/storage/v2017_10_01/_metadata.json | 4 +- .../v2017_10_01/_storage_management.py | 28 +- .../mgmt/storage/v2017_10_01/_version.py | 2 +- .../mgmt/storage/v2017_10_01/aio/__init__.py | 13 +- .../storage/v2017_10_01/aio/_configuration.py | 12 +- .../v2017_10_01/aio/_storage_management.py | 26 +- .../v2017_10_01/aio/operations/__init__.py | 5 + .../v2017_10_01/aio/operations/_operations.py | 64 +- .../v2017_10_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 361 +- .../aio/operations/_usage_operations.py | 64 +- .../storage/v2017_10_01/models/__init__.py | 6 +- .../storage/v2017_10_01/models/_models_py3.py | 206 +- .../mgmt/storage/v2017_10_01/models/_patch.py | 19 + .../models/_storage_management_enums.py | 39 +- .../v2017_10_01/operations/__init__.py | 5 + .../v2017_10_01/operations/_operations.py | 90 +- .../storage/v2017_10_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 652 +- .../operations/_usage_operations.py | 92 +- .../mgmt/storage/v2018_02_01/__init__.py | 13 +- .../storage/v2018_02_01/_configuration.py | 9 +- .../mgmt/storage/v2018_02_01/_metadata.json | 4 +- .../v2018_02_01/_storage_management_client.py | 32 +- .../mgmt/storage/v2018_02_01/_version.py | 2 +- .../mgmt/storage/v2018_02_01/aio/__init__.py | 13 +- .../storage/v2018_02_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 30 +- .../v2018_02_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 395 +- .../v2018_02_01/aio/operations/_operations.py | 64 +- .../v2018_02_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 361 +- .../aio/operations/_usage_operations.py | 93 +- .../storage/v2018_02_01/models/__init__.py | 6 +- .../storage/v2018_02_01/models/_models_py3.py | 252 +- .../mgmt/storage/v2018_02_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 53 +- .../v2018_02_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 755 +- .../v2018_02_01/operations/_operations.py | 90 +- .../storage/v2018_02_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 652 +- .../operations/_usage_operations.py | 145 +- .../storage/v2018_03_01_preview/__init__.py | 13 +- .../v2018_03_01_preview/_configuration.py | 9 +- .../v2018_03_01_preview/_metadata.json | 4 +- .../_storage_management_client.py | 32 +- .../storage/v2018_03_01_preview/_version.py | 2 +- .../v2018_03_01_preview/aio/__init__.py | 13 +- .../v2018_03_01_preview/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 30 +- .../aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 395 +- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 436 +- .../aio/operations/_usages_operations.py | 93 +- .../v2018_03_01_preview/models/__init__.py | 6 +- .../v2018_03_01_preview/models/_models_py3.py | 252 +- .../v2018_03_01_preview/models/_patch.py | 19 + .../_storage_management_client_enums.py | 55 +- .../operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 755 +- .../operations/_operations.py | 90 +- .../v2018_03_01_preview/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 795 +- .../operations/_usages_operations.py | 145 +- .../mgmt/storage/v2018_07_01/__init__.py | 13 +- .../storage/v2018_07_01/_configuration.py | 2 +- .../mgmt/storage/v2018_07_01/_metadata.json | 4 +- .../v2018_07_01/_storage_management_client.py | 39 +- .../mgmt/storage/v2018_07_01/_version.py | 2 +- .../mgmt/storage/v2018_07_01/aio/__init__.py | 13 +- .../storage/v2018_07_01/aio/_configuration.py | 2 +- .../aio/_storage_management_client.py | 37 +- .../v2018_07_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 434 +- .../operations/_blob_services_operations.py | 103 +- .../_management_policies_operations.py | 118 +- .../v2018_07_01/aio/operations/_operations.py | 67 +- .../v2018_07_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 67 +- .../_storage_accounts_operations.py | 451 +- .../aio/operations/_usages_operations.py | 67 +- .../storage/v2018_07_01/models/__init__.py | 6 +- .../storage/v2018_07_01/models/_models_py3.py | 267 +- .../mgmt/storage/v2018_07_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 59 +- .../v2018_07_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 794 +- .../operations/_blob_services_operations.py | 166 +- .../_management_policies_operations.py | 192 +- .../v2018_07_01/operations/_operations.py | 93 +- .../storage/v2018_07_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 95 +- .../_storage_accounts_operations.py | 759 +- .../operations/_usages_operations.py | 95 +- .../mgmt/storage/v2018_11_01/__init__.py | 13 +- .../storage/v2018_11_01/_configuration.py | 9 +- .../mgmt/storage/v2018_11_01/_metadata.json | 4 +- .../v2018_11_01/_storage_management_client.py | 42 +- .../mgmt/storage/v2018_11_01/_version.py | 2 +- .../mgmt/storage/v2018_11_01/aio/__init__.py | 13 +- .../storage/v2018_11_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 40 +- .../v2018_11_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 395 +- .../operations/_blob_services_operations.py | 97 +- .../_management_policies_operations.py | 109 +- .../v2018_11_01/aio/operations/_operations.py | 64 +- .../v2018_11_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 439 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2018_11_01/models/__init__.py | 6 +- .../storage/v2018_11_01/models/_models_py3.py | 295 +- .../mgmt/storage/v2018_11_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 61 +- .../v2018_11_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 755 +- .../operations/_blob_services_operations.py | 160 +- .../_management_policies_operations.py | 183 +- .../v2018_11_01/operations/_operations.py | 90 +- .../storage/v2018_11_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 762 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2019_04_01/__init__.py | 13 +- .../storage/v2019_04_01/_configuration.py | 9 +- .../mgmt/storage/v2019_04_01/_metadata.json | 4 +- .../v2019_04_01/_storage_management_client.py | 50 +- .../mgmt/storage/v2019_04_01/_version.py | 2 +- .../mgmt/storage/v2019_04_01/aio/__init__.py | 13 +- .../storage/v2019_04_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 48 +- .../v2019_04_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 406 +- .../operations/_blob_services_operations.py | 126 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 171 +- .../_management_policies_operations.py | 109 +- .../v2019_04_01/aio/operations/_operations.py | 64 +- .../v2019_04_01/aio/operations/_patch.py | 19 + .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 443 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2019_04_01/models/__init__.py | 6 +- .../storage/v2019_04_01/models/_models_py3.py | 365 +- .../mgmt/storage/v2019_04_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 67 +- .../v2019_04_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 772 +- .../operations/_blob_services_operations.py | 213 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 313 +- .../_management_policies_operations.py | 183 +- .../v2019_04_01/operations/_operations.py | 90 +- .../storage/v2019_04_01/operations/_patch.py | 19 + .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 768 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2019_06_01/__init__.py | 13 +- .../storage/v2019_06_01/_configuration.py | 9 +- .../mgmt/storage/v2019_06_01/_metadata.json | 4 +- .../v2019_06_01/_storage_management_client.py | 86 +- .../mgmt/storage/v2019_06_01/_version.py | 2 +- .../mgmt/storage/v2019_06_01/aio/__init__.py | 13 +- .../storage/v2019_06_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 84 +- .../v2019_06_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 405 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 204 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2019_06_01/aio/operations/_operations.py | 64 +- .../v2019_06_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 505 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2019_06_01/models/__init__.py | 6 +- .../storage/v2019_06_01/models/_models_py3.py | 565 +- .../mgmt/storage/v2019_06_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 99 +- .../v2019_06_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 771 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 377 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2019_06_01/operations/_operations.py | 90 +- .../storage/v2019_06_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 859 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../storage/v2020_08_01_preview/__init__.py | 13 +- .../v2020_08_01_preview/_configuration.py | 9 +- .../v2020_08_01_preview/_metadata.json | 4 +- .../_storage_management_client.py | 90 +- .../storage/v2020_08_01_preview/_version.py | 2 +- .../v2020_08_01_preview/aio/__init__.py | 13 +- .../v2020_08_01_preview/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 88 +- .../aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 405 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 211 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../aio/operations/_operations.py | 64 +- .../aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 505 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../v2020_08_01_preview/models/__init__.py | 6 +- .../v2020_08_01_preview/models/_models_py3.py | 583 +- .../v2020_08_01_preview/models/_patch.py | 19 + .../_storage_management_client_enums.py | 103 +- .../operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 771 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 390 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../operations/_operations.py | 90 +- .../v2020_08_01_preview/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 859 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_01_01/__init__.py | 13 +- .../storage/v2021_01_01/_configuration.py | 9 +- .../mgmt/storage/v2021_01_01/_metadata.json | 4 +- .../v2021_01_01/_storage_management_client.py | 90 +- .../mgmt/storage/v2021_01_01/_version.py | 2 +- .../mgmt/storage/v2021_01_01/aio/__init__.py | 13 +- .../storage/v2021_01_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 88 +- .../v2021_01_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 405 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 210 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_01_01/aio/operations/_operations.py | 64 +- .../v2021_01_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 505 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_01_01/models/__init__.py | 6 +- .../storage/v2021_01_01/models/_models_py3.py | 593 +- .../mgmt/storage/v2021_01_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 107 +- .../v2021_01_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 771 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 389 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_01_01/operations/_operations.py | 90 +- .../storage/v2021_01_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 859 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_02_01/__init__.py | 13 +- .../storage/v2021_02_01/_configuration.py | 9 +- .../mgmt/storage/v2021_02_01/_metadata.json | 4 +- .../v2021_02_01/_storage_management_client.py | 90 +- .../mgmt/storage/v2021_02_01/_version.py | 2 +- .../mgmt/storage/v2021_02_01/aio/__init__.py | 13 +- .../storage/v2021_02_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 88 +- .../v2021_02_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 405 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 210 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_02_01/aio/operations/_operations.py | 64 +- .../v2021_02_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 505 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_02_01/models/__init__.py | 6 +- .../storage/v2021_02_01/models/_models_py3.py | 611 +- .../mgmt/storage/v2021_02_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 109 +- .../v2021_02_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 771 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 389 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_02_01/operations/_operations.py | 90 +- .../storage/v2021_02_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 859 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_04_01/__init__.py | 13 +- .../storage/v2021_04_01/_configuration.py | 9 +- .../mgmt/storage/v2021_04_01/_metadata.json | 4 +- .../v2021_04_01/_storage_management_client.py | 90 +- .../mgmt/storage/v2021_04_01/_version.py | 2 +- .../mgmt/storage/v2021_04_01/aio/__init__.py | 13 +- .../storage/v2021_04_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 88 +- .../v2021_04_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 457 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 240 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_04_01/aio/operations/_operations.py | 64 +- .../v2021_04_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 505 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_04_01/models/__init__.py | 6 +- .../storage/v2021_04_01/models/_models_py3.py | 675 +- .../mgmt/storage/v2021_04_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 117 +- .../v2021_04_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 847 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 452 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_04_01/operations/_operations.py | 90 +- .../storage/v2021_04_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 859 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_06_01/__init__.py | 13 +- .../storage/v2021_06_01/_configuration.py | 9 +- .../mgmt/storage/v2021_06_01/_metadata.json | 4 +- .../v2021_06_01/_storage_management_client.py | 90 +- .../mgmt/storage/v2021_06_01/_version.py | 2 +- .../mgmt/storage/v2021_06_01/aio/__init__.py | 13 +- .../storage/v2021_06_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 88 +- .../v2021_06_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 457 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 240 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_06_01/aio/operations/_operations.py | 64 +- .../v2021_06_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 611 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_06_01/models/__init__.py | 6 +- .../storage/v2021_06_01/models/_models_py3.py | 715 +- .../mgmt/storage/v2021_06_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 121 +- .../v2021_06_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 847 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 452 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_06_01/operations/_operations.py | 90 +- .../storage/v2021_06_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 1013 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_08_01/__init__.py | 13 +- .../storage/v2021_08_01/_configuration.py | 9 +- .../mgmt/storage/v2021_08_01/_metadata.json | 4 +- .../v2021_08_01/_storage_management_client.py | 94 +- .../mgmt/storage/v2021_08_01/_version.py | 2 +- .../mgmt/storage/v2021_08_01/aio/__init__.py | 13 +- .../storage/v2021_08_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 92 +- .../v2021_08_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 457 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 240 +- .../aio/operations/_local_users_operations.py | 186 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_08_01/aio/operations/_operations.py | 64 +- .../v2021_08_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 611 +- .../aio/operations/_table_operations.py | 159 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_08_01/models/__init__.py | 6 +- .../storage/v2021_08_01/models/_models_py3.py | 747 +- .../mgmt/storage/v2021_08_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 125 +- .../v2021_08_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 847 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 452 +- .../operations/_local_users_operations.py | 341 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_08_01/operations/_operations.py | 90 +- .../storage/v2021_08_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 1013 +- .../operations/_table_operations.py | 284 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2021_09_01/__init__.py | 13 +- .../storage/v2021_09_01/_configuration.py | 9 +- .../mgmt/storage/v2021_09_01/_metadata.json | 4 +- .../v2021_09_01/_storage_management_client.py | 94 +- .../mgmt/storage/v2021_09_01/_version.py | 2 +- .../mgmt/storage/v2021_09_01/aio/__init__.py | 13 +- .../storage/v2021_09_01/aio/_configuration.py | 9 +- .../aio/_storage_management_client.py | 92 +- .../v2021_09_01/aio/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 457 +- .../_blob_inventory_policies_operations.py | 138 +- .../operations/_blob_services_operations.py | 126 +- .../_deleted_accounts_operations.py | 87 +- .../_encryption_scopes_operations.py | 141 +- .../operations/_file_services_operations.py | 121 +- .../aio/operations/_file_shares_operations.py | 240 +- .../aio/operations/_local_users_operations.py | 186 +- .../_management_policies_operations.py | 109 +- ..._object_replication_policies_operations.py | 138 +- .../v2021_09_01/aio/operations/_operations.py | 64 +- .../v2021_09_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 138 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 169 +- .../operations/_queue_services_operations.py | 121 +- .../aio/operations/_skus_operations.py | 64 +- .../_storage_accounts_operations.py | 611 +- .../aio/operations/_table_operations.py | 169 +- .../operations/_table_services_operations.py | 121 +- .../aio/operations/_usages_operations.py | 64 +- .../storage/v2021_09_01/models/__init__.py | 6 +- .../storage/v2021_09_01/models/_models_py3.py | 787 +- .../mgmt/storage/v2021_09_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 129 +- .../v2021_09_01/operations/__init__.py | 5 + .../operations/_blob_containers_operations.py | 847 +- .../_blob_inventory_policies_operations.py | 245 +- .../operations/_blob_services_operations.py | 213 +- .../_deleted_accounts_operations.py | 140 +- .../_encryption_scopes_operations.py | 253 +- .../operations/_file_services_operations.py | 208 +- .../operations/_file_shares_operations.py | 452 +- .../operations/_local_users_operations.py | 341 +- .../_management_policies_operations.py | 183 +- ..._object_replication_policies_operations.py | 245 +- .../v2021_09_01/operations/_operations.py | 90 +- .../storage/v2021_09_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 245 +- .../_private_link_resources_operations.py | 87 +- .../operations/_queue_operations.py | 309 +- .../operations/_queue_services_operations.py | 208 +- .../operations/_skus_operations.py | 92 +- .../_storage_accounts_operations.py | 1013 +- .../operations/_table_operations.py | 305 +- .../operations/_table_services_operations.py | 208 +- .../operations/_usages_operations.py | 92 +- .../mgmt/storage/v2022_05_01/__init__.py | 23 + .../storage/v2022_05_01/_configuration.py | 73 + .../mgmt/storage/v2022_05_01/_metadata.json | 121 + .../azure/mgmt/storage/v2022_05_01/_patch.py | 19 + .../v2022_05_01/_storage_management_client.py | 200 + .../azure/mgmt/storage/v2022_05_01/_vendor.py | 27 + .../mgmt/storage/v2022_05_01/_version.py | 9 + .../mgmt/storage/v2022_05_01/aio/__init__.py | 20 + .../storage/v2022_05_01/aio/_configuration.py | 72 + .../mgmt/storage/v2022_05_01/aio/_patch.py | 19 + .../aio/_storage_management_client.py | 200 + .../v2022_05_01/aio/operations/__init__.py | 56 + .../operations/_blob_containers_operations.py | 1307 +++ .../_blob_inventory_policies_operations.py | 358 + .../operations/_blob_services_operations.py | 291 + .../_deleted_accounts_operations.py | 190 + .../_encryption_scopes_operations.py | 381 + .../operations/_file_services_operations.py | 263 + .../aio/operations/_file_shares_operations.py | 661 ++ .../aio/operations/_local_users_operations.py | 501 + .../_management_policies_operations.py | 262 + ..._object_replication_policies_operations.py | 365 + .../v2022_05_01/aio/operations/_operations.py | 121 + .../v2022_05_01/aio/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 357 + .../_private_link_resources_operations.py | 109 + .../aio/operations/_queue_operations.py | 451 + .../operations/_queue_services_operations.py | 263 + .../aio/operations/_skus_operations.py | 124 + .../_storage_accounts_operations.py | 1524 +++ .../aio/operations/_table_operations.py | 441 + .../operations/_table_services_operations.py | 263 + .../aio/operations/_usages_operations.py | 129 + .../storage/v2022_05_01/models/__init__.py | 443 + .../storage/v2022_05_01/models/_models_py3.py | 8369 +++++++++++++++++ .../mgmt/storage/v2022_05_01/models/_patch.py | 19 + .../_storage_management_client_enums.py | 549 ++ .../v2022_05_01/operations/__init__.py | 56 + .../operations/_blob_containers_operations.py | 1932 ++++ .../_blob_inventory_policies_operations.py | 522 + .../operations/_blob_services_operations.py | 415 + .../_deleted_accounts_operations.py | 262 + .../_encryption_scopes_operations.py | 553 ++ .../operations/_file_services_operations.py | 389 + .../operations/_file_shares_operations.py | 995 ++ .../operations/_local_users_operations.py | 742 ++ .../_management_policies_operations.py | 383 + ..._object_replication_policies_operations.py | 529 ++ .../v2022_05_01/operations/_operations.py | 151 + .../storage/v2022_05_01/operations/_patch.py | 19 + ...private_endpoint_connections_operations.py | 521 + .../_private_link_resources_operations.py | 149 + .../operations/_queue_operations.py | 668 ++ .../operations/_queue_services_operations.py | 389 + .../operations/_skus_operations.py | 160 + .../_storage_accounts_operations.py | 2152 +++++ .../operations/_table_operations.py | 651 ++ .../operations/_table_services_operations.py | 389 + .../operations/_usages_operations.py | 166 + .../azure/mgmt/storage/v2022_05_01/py.typed | 1 + sdk/storage/azure-mgmt-storage/setup.py | 9 +- shared_requirements.txt | 2 +- 758 files changed, 96246 insertions(+), 37704 deletions(-) create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/py.typed diff --git a/sdk/storage/azure-mgmt-storage/CHANGELOG.md b/sdk/storage/azure-mgmt-storage/CHANGELOG.md index 24ec4e715338..54fbaff7a54f 100644 --- a/sdk/storage/azure-mgmt-storage/CHANGELOG.md +++ b/sdk/storage/azure-mgmt-storage/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 20.1.0 (2022-08-09) + +**Features** + + - Added model AllowedMethods + - Added model LeaseContainerRequestEnum + ## 20.0.0 (2022-04-06) **Features** diff --git a/sdk/storage/azure-mgmt-storage/MANIFEST.in b/sdk/storage/azure-mgmt-storage/MANIFEST.in index bcd63177d8d3..ba13e7ff0588 100644 --- a/sdk/storage/azure-mgmt-storage/MANIFEST.in +++ b/sdk/storage/azure-mgmt-storage/MANIFEST.in @@ -1,5 +1,5 @@ include _meta.json -recursive-include tests *.py *.yaml +recursive-include tests *.py *.json include *.md include azure/__init__.py include azure/mgmt/__init__.py diff --git a/sdk/storage/azure-mgmt-storage/README.md b/sdk/storage/azure-mgmt-storage/README.md index bbe25f226afd..7c316c1af252 100644 --- a/sdk/storage/azure-mgmt-storage/README.md +++ b/sdk/storage/azure-mgmt-storage/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Storage Management Client Library. -This package has been tested with Python 3.6+. +This package has been tested with Python 3.7+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ diff --git a/sdk/storage/azure-mgmt-storage/_meta.json b/sdk/storage/azure-mgmt-storage/_meta.json index e4c569085d46..c8ac11333c76 100644 --- a/sdk/storage/azure-mgmt-storage/_meta.json +++ b/sdk/storage/azure-mgmt-storage/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.12.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "3026119ab41bbce77275cfa3a1afbabf43af5aea", + "commit": "1b3b9c1dd4d2c875997ea0b392dc71418fb1f28d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/storage/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/storage/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", "readme": "specification/storage/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py index e59cf3a5c122..3af552133413 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration @@ -55,7 +56,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-05-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -107,6 +108,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-06-01: :mod:`v2021_06_01.models` * 2021-08-01: :mod:`v2021_08_01.models` * 2021-09-01: :mod:`v2021_09_01.models` + * 2022-05-01: :mod:`v2022_05_01.models` """ if api_version == '2015-06-15': from .v2015_06_15 import models @@ -162,6 +164,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-01': from .v2021_09_01 import models return models + elif api_version == '2022-05-01': + from .v2022_05_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -181,6 +186,7 @@ def blob_containers(self): * 2021-06-01: :class:`BlobContainersOperations` * 2021-08-01: :class:`BlobContainersOperations` * 2021-09-01: :class:`BlobContainersOperations` + * 2022-05-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -209,6 +215,8 @@ def blob_containers(self): from .v2021_08_01.operations import BlobContainersOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import BlobContainersOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -225,6 +233,7 @@ def blob_inventory_policies(self): * 2021-06-01: :class:`BlobInventoryPoliciesOperations` * 2021-08-01: :class:`BlobInventoryPoliciesOperations` * 2021-09-01: :class:`BlobInventoryPoliciesOperations` + * 2022-05-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -243,6 +252,8 @@ def blob_inventory_policies(self): from .v2021_08_01.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -262,6 +273,7 @@ def blob_services(self): * 2021-06-01: :class:`BlobServicesOperations` * 2021-08-01: :class:`BlobServicesOperations` * 2021-09-01: :class:`BlobServicesOperations` + * 2022-05-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -286,6 +298,8 @@ def blob_services(self): from .v2021_08_01.operations import BlobServicesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import BlobServicesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -301,6 +315,7 @@ def deleted_accounts(self): * 2021-06-01: :class:`DeletedAccountsOperations` * 2021-08-01: :class:`DeletedAccountsOperations` * 2021-09-01: :class:`DeletedAccountsOperations` + * 2022-05-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -317,6 +332,8 @@ def deleted_accounts(self): from .v2021_08_01.operations import DeletedAccountsOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -333,6 +350,7 @@ def encryption_scopes(self): * 2021-06-01: :class:`EncryptionScopesOperations` * 2021-08-01: :class:`EncryptionScopesOperations` * 2021-09-01: :class:`EncryptionScopesOperations` + * 2022-05-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -351,6 +369,8 @@ def encryption_scopes(self): from .v2021_08_01.operations import EncryptionScopesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -368,6 +388,7 @@ def file_services(self): * 2021-06-01: :class:`FileServicesOperations` * 2021-08-01: :class:`FileServicesOperations` * 2021-09-01: :class:`FileServicesOperations` + * 2022-05-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -388,6 +409,8 @@ def file_services(self): from .v2021_08_01.operations import FileServicesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import FileServicesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -405,6 +428,7 @@ def file_shares(self): * 2021-06-01: :class:`FileSharesOperations` * 2021-08-01: :class:`FileSharesOperations` * 2021-09-01: :class:`FileSharesOperations` + * 2022-05-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -425,6 +449,8 @@ def file_shares(self): from .v2021_08_01.operations import FileSharesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import FileSharesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -435,12 +461,15 @@ def local_users(self): * 2021-08-01: :class:`LocalUsersOperations` * 2021-09-01: :class:`LocalUsersOperations` + * 2022-05-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': from .v2021_08_01.operations import LocalUsersOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import LocalUsersOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -460,6 +489,7 @@ def management_policies(self): * 2021-06-01: :class:`ManagementPoliciesOperations` * 2021-08-01: :class:`ManagementPoliciesOperations` * 2021-09-01: :class:`ManagementPoliciesOperations` + * 2022-05-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-07-01': @@ -484,6 +514,8 @@ def management_policies(self): from .v2021_08_01.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -500,6 +532,7 @@ def object_replication_policies(self): * 2021-06-01: :class:`ObjectReplicationPoliciesOperations` * 2021-08-01: :class:`ObjectReplicationPoliciesOperations` * 2021-09-01: :class:`ObjectReplicationPoliciesOperations` + * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -518,6 +551,8 @@ def object_replication_policies(self): from .v2021_08_01.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -541,6 +576,7 @@ def operations(self): * 2021-06-01: :class:`Operations` * 2021-08-01: :class:`Operations` * 2021-09-01: :class:`Operations` + * 2022-05-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -573,6 +609,8 @@ def operations(self): from .v2021_08_01.operations import Operations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import Operations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -589,6 +627,7 @@ def private_endpoint_connections(self): * 2021-06-01: :class:`PrivateEndpointConnectionsOperations` * 2021-08-01: :class:`PrivateEndpointConnectionsOperations` * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -607,6 +646,8 @@ def private_endpoint_connections(self): from .v2021_08_01.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -623,6 +664,7 @@ def private_link_resources(self): * 2021-06-01: :class:`PrivateLinkResourcesOperations` * 2021-08-01: :class:`PrivateLinkResourcesOperations` * 2021-09-01: :class:`PrivateLinkResourcesOperations` + * 2022-05-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -641,6 +683,8 @@ def private_link_resources(self): from .v2021_08_01.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -657,6 +701,7 @@ def queue(self): * 2021-06-01: :class:`QueueOperations` * 2021-08-01: :class:`QueueOperations` * 2021-09-01: :class:`QueueOperations` + * 2022-05-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -675,6 +720,8 @@ def queue(self): from .v2021_08_01.operations import QueueOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import QueueOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -691,6 +738,7 @@ def queue_services(self): * 2021-06-01: :class:`QueueServicesOperations` * 2021-08-01: :class:`QueueServicesOperations` * 2021-09-01: :class:`QueueServicesOperations` + * 2022-05-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -709,6 +757,8 @@ def queue_services(self): from .v2021_08_01.operations import QueueServicesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import QueueServicesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -732,6 +782,7 @@ def skus(self): * 2021-06-01: :class:`SkusOperations` * 2021-08-01: :class:`SkusOperations` * 2021-09-01: :class:`SkusOperations` + * 2022-05-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -764,6 +815,8 @@ def skus(self): from .v2021_08_01.operations import SkusOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import SkusOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -790,6 +843,7 @@ def storage_accounts(self): * 2021-06-01: :class:`StorageAccountsOperations` * 2021-08-01: :class:`StorageAccountsOperations` * 2021-09-01: :class:`StorageAccountsOperations` + * 2022-05-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -828,6 +882,8 @@ def storage_accounts(self): from .v2021_08_01.operations import StorageAccountsOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import StorageAccountsOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -844,6 +900,7 @@ def table(self): * 2021-06-01: :class:`TableOperations` * 2021-08-01: :class:`TableOperations` * 2021-09-01: :class:`TableOperations` + * 2022-05-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -862,6 +919,8 @@ def table(self): from .v2021_08_01.operations import TableOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import TableOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -878,6 +937,7 @@ def table_services(self): * 2021-06-01: :class:`TableServicesOperations` * 2021-08-01: :class:`TableServicesOperations` * 2021-09-01: :class:`TableServicesOperations` + * 2022-05-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -896,6 +956,8 @@ def table_services(self): from .v2021_08_01.operations import TableServicesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import TableServicesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -944,6 +1006,7 @@ def usages(self): * 2021-06-01: :class:`UsagesOperations` * 2021-08-01: :class:`UsagesOperations` * 2021-09-01: :class:`UsagesOperations` + * 2022-05-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -970,6 +1033,8 @@ def usages(self): from .v2021_08_01.operations import UsagesOperations as OperationClass elif api_version == '2021-09-01': from .v2021_09_01.operations import UsagesOperations as OperationClass + elif api_version == '2022-05-01': + from .v2022_05_01.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py index f6add466b56c..4bd561a0e67d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py index 2aadcf97c430..c2b5fb27c697 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py @@ -11,10 +11,11 @@ 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 msrest import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration @@ -54,7 +55,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2021-09-01' + DEFAULT_API_VERSION = '2022-05-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -106,6 +107,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-06-01: :mod:`v2021_06_01.models` * 2021-08-01: :mod:`v2021_08_01.models` * 2021-09-01: :mod:`v2021_09_01.models` + * 2022-05-01: :mod:`v2022_05_01.models` """ if api_version == '2015-06-15': from ..v2015_06_15 import models @@ -161,6 +163,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-09-01': from ..v2021_09_01 import models return models + elif api_version == '2022-05-01': + from ..v2022_05_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -180,6 +185,7 @@ def blob_containers(self): * 2021-06-01: :class:`BlobContainersOperations` * 2021-08-01: :class:`BlobContainersOperations` * 2021-09-01: :class:`BlobContainersOperations` + * 2022-05-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -208,6 +214,8 @@ def blob_containers(self): from ..v2021_08_01.aio.operations import BlobContainersOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import BlobContainersOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -224,6 +232,7 @@ def blob_inventory_policies(self): * 2021-06-01: :class:`BlobInventoryPoliciesOperations` * 2021-08-01: :class:`BlobInventoryPoliciesOperations` * 2021-09-01: :class:`BlobInventoryPoliciesOperations` + * 2022-05-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -242,6 +251,8 @@ def blob_inventory_policies(self): from ..v2021_08_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -261,6 +272,7 @@ def blob_services(self): * 2021-06-01: :class:`BlobServicesOperations` * 2021-08-01: :class:`BlobServicesOperations` * 2021-09-01: :class:`BlobServicesOperations` + * 2022-05-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -285,6 +297,8 @@ def blob_services(self): from ..v2021_08_01.aio.operations import BlobServicesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import BlobServicesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -300,6 +314,7 @@ def deleted_accounts(self): * 2021-06-01: :class:`DeletedAccountsOperations` * 2021-08-01: :class:`DeletedAccountsOperations` * 2021-09-01: :class:`DeletedAccountsOperations` + * 2022-05-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -316,6 +331,8 @@ def deleted_accounts(self): from ..v2021_08_01.aio.operations import DeletedAccountsOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -332,6 +349,7 @@ def encryption_scopes(self): * 2021-06-01: :class:`EncryptionScopesOperations` * 2021-08-01: :class:`EncryptionScopesOperations` * 2021-09-01: :class:`EncryptionScopesOperations` + * 2022-05-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -350,6 +368,8 @@ def encryption_scopes(self): from ..v2021_08_01.aio.operations import EncryptionScopesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -367,6 +387,7 @@ def file_services(self): * 2021-06-01: :class:`FileServicesOperations` * 2021-08-01: :class:`FileServicesOperations` * 2021-09-01: :class:`FileServicesOperations` + * 2022-05-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -387,6 +408,8 @@ def file_services(self): from ..v2021_08_01.aio.operations import FileServicesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import FileServicesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -404,6 +427,7 @@ def file_shares(self): * 2021-06-01: :class:`FileSharesOperations` * 2021-08-01: :class:`FileSharesOperations` * 2021-09-01: :class:`FileSharesOperations` + * 2022-05-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -424,6 +448,8 @@ def file_shares(self): from ..v2021_08_01.aio.operations import FileSharesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import FileSharesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -434,12 +460,15 @@ def local_users(self): * 2021-08-01: :class:`LocalUsersOperations` * 2021-09-01: :class:`LocalUsersOperations` + * 2022-05-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': from ..v2021_08_01.aio.operations import LocalUsersOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import LocalUsersOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -459,6 +488,7 @@ def management_policies(self): * 2021-06-01: :class:`ManagementPoliciesOperations` * 2021-08-01: :class:`ManagementPoliciesOperations` * 2021-09-01: :class:`ManagementPoliciesOperations` + * 2022-05-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-07-01': @@ -483,6 +513,8 @@ def management_policies(self): from ..v2021_08_01.aio.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -499,6 +531,7 @@ def object_replication_policies(self): * 2021-06-01: :class:`ObjectReplicationPoliciesOperations` * 2021-08-01: :class:`ObjectReplicationPoliciesOperations` * 2021-09-01: :class:`ObjectReplicationPoliciesOperations` + * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -517,6 +550,8 @@ def object_replication_policies(self): from ..v2021_08_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -540,6 +575,7 @@ def operations(self): * 2021-06-01: :class:`Operations` * 2021-08-01: :class:`Operations` * 2021-09-01: :class:`Operations` + * 2022-05-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -572,6 +608,8 @@ def operations(self): from ..v2021_08_01.aio.operations import Operations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import Operations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -588,6 +626,7 @@ def private_endpoint_connections(self): * 2021-06-01: :class:`PrivateEndpointConnectionsOperations` * 2021-08-01: :class:`PrivateEndpointConnectionsOperations` * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -606,6 +645,8 @@ def private_endpoint_connections(self): from ..v2021_08_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -622,6 +663,7 @@ def private_link_resources(self): * 2021-06-01: :class:`PrivateLinkResourcesOperations` * 2021-08-01: :class:`PrivateLinkResourcesOperations` * 2021-09-01: :class:`PrivateLinkResourcesOperations` + * 2022-05-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -640,6 +682,8 @@ def private_link_resources(self): from ..v2021_08_01.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -656,6 +700,7 @@ def queue(self): * 2021-06-01: :class:`QueueOperations` * 2021-08-01: :class:`QueueOperations` * 2021-09-01: :class:`QueueOperations` + * 2022-05-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -674,6 +719,8 @@ def queue(self): from ..v2021_08_01.aio.operations import QueueOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import QueueOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -690,6 +737,7 @@ def queue_services(self): * 2021-06-01: :class:`QueueServicesOperations` * 2021-08-01: :class:`QueueServicesOperations` * 2021-09-01: :class:`QueueServicesOperations` + * 2022-05-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -708,6 +756,8 @@ def queue_services(self): from ..v2021_08_01.aio.operations import QueueServicesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import QueueServicesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -731,6 +781,7 @@ def skus(self): * 2021-06-01: :class:`SkusOperations` * 2021-08-01: :class:`SkusOperations` * 2021-09-01: :class:`SkusOperations` + * 2022-05-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -763,6 +814,8 @@ def skus(self): from ..v2021_08_01.aio.operations import SkusOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import SkusOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -789,6 +842,7 @@ def storage_accounts(self): * 2021-06-01: :class:`StorageAccountsOperations` * 2021-08-01: :class:`StorageAccountsOperations` * 2021-09-01: :class:`StorageAccountsOperations` + * 2022-05-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -827,6 +881,8 @@ def storage_accounts(self): from ..v2021_08_01.aio.operations import StorageAccountsOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import StorageAccountsOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -843,6 +899,7 @@ def table(self): * 2021-06-01: :class:`TableOperations` * 2021-08-01: :class:`TableOperations` * 2021-09-01: :class:`TableOperations` + * 2022-05-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -861,6 +918,8 @@ def table(self): from ..v2021_08_01.aio.operations import TableOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import TableOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -877,6 +936,7 @@ def table_services(self): * 2021-06-01: :class:`TableServicesOperations` * 2021-08-01: :class:`TableServicesOperations` * 2021-09-01: :class:`TableServicesOperations` + * 2022-05-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -895,6 +955,8 @@ def table_services(self): from ..v2021_08_01.aio.operations import TableServicesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import TableServicesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -943,6 +1005,7 @@ def usages(self): * 2021-06-01: :class:`UsagesOperations` * 2021-08-01: :class:`UsagesOperations` * 2021-09-01: :class:`UsagesOperations` + * 2022-05-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -969,6 +1032,8 @@ def usages(self): from ..v2021_08_01.aio.operations import UsagesOperations as OperationClass elif api_version == '2021-09-01': from ..v2021_09_01.aio.operations import UsagesOperations as OperationClass + elif api_version == '2022-05-01': + from ..v2022_05_01.aio.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py index e1bc2fdf12d8..d447da56e626 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- from .v2018_02_01.models import * -from .v2021_09_01.models import * +from .v2022_05_01.models import * diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py index b1e55270b061..7be55ff4bf05 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py index fd310faa779e..28ef888ae349 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-15") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-15" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json index a93001c0fc16..fbff37b91208 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"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\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py index 056e84f5b9bd..d7678c956b88 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementConfiguration @@ -33,8 +34,11 @@ class StorageManagement: :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -53,13 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py index 95bb9e0d6b2c..36895a3e2a36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management import StorageManagement + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py index f084495f1d55..99a9890858e9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-15") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-15" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py index 32852864a1b5..6c47e38bec8f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementConfiguration @@ -34,8 +35,11 @@ class StorageManagement: :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-15". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -54,8 +58,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py index e612fa80a4eb..82269b233b7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2015_06_15.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2015_06_15.aio.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -61,31 +61,44 @@ async def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +112,28 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +141,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +171,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +179,11 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -171,6 +198,9 @@ async def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -185,35 +215,46 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, content_type=content_type, + 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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +263,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +288,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +326,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +335,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +352,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +394,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +402,11 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -359,18 +425,24 @@ async def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +450,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +478,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +496,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +543,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +560,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +581,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +630,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +647,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +655,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountKeys": + ) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +670,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +712,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +720,11 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccountKeys": + ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -614,18 +737,24 @@ async def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountKeys, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +762,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,5 +790,5 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py index aeae13f705f9..3119adf4f824 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2015_06_15.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2015_06_15.aio.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Lists the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py index 35b2382afcfd..15a5eea909c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py @@ -29,7 +29,9 @@ Reason, UsageUnit, ) - +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__ = [ 'CheckNameAvailabilityResult', 'CustomDomain', @@ -51,3 +53,5 @@ 'Reason', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py index a58a35e72490..e06471542fbc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class CheckNameAvailabilityResult(msrest.serialization.Model): @@ -22,7 +24,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: The reason that a storage account name could not be used. The Reason element is - only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2015_06_15.models.Reason :ivar message: The error message explaining the Reason value in more detail. @@ -39,7 +41,7 @@ def __init__( self, *, name_available: Optional[bool] = None, - reason: Optional[Union[str, "Reason"]] = None, + reason: Optional[Union[str, "_models.Reason"]] = None, message: Optional[str] = None, **kwargs ): @@ -49,7 +51,7 @@ def __init__( and cannot be used. :paramtype name_available: bool :keyword reason: The reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :paramtype reason: str or ~azure.mgmt.storage.v2015_06_15.models.Reason :keyword message: The error message explaining the Reason value in more detail. @@ -215,9 +217,9 @@ class StorageAccount(Resource): :ivar tags: A set of tags. Resource tags. :vartype tags: dict[str, str] :ivar provisioning_state: The status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2015_06_15.models.ProvisioningState - :ivar account_type: The type of the storage account. Possible values include: "Standard_LRS", + :ivar account_type: The type of the storage account. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :ivar primary_endpoints: The URLs that are used to perform a retrieval of a public blob, queue, @@ -226,7 +228,7 @@ class StorageAccount(Resource): :ivar primary_location: The location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: The status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available", "Unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :ivar last_geo_failover_time: The timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if @@ -238,7 +240,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: The status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available", "Unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :ivar creation_time: The creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -280,17 +282,17 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - account_type: Optional[Union[str, "AccountType"]] = None, - primary_endpoints: Optional["Endpoints"] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, + primary_endpoints: Optional["_models.Endpoints"] = None, primary_location: Optional[str] = None, - status_of_primary: Optional[Union[str, "AccountStatus"]] = None, + status_of_primary: Optional[Union[str, "_models.AccountStatus"]] = None, last_geo_failover_time: Optional[datetime.datetime] = None, secondary_location: Optional[str] = None, - status_of_secondary: Optional[Union[str, "AccountStatus"]] = None, + status_of_secondary: Optional[Union[str, "_models.AccountStatus"]] = None, creation_time: Optional[datetime.datetime] = None, - custom_domain: Optional["CustomDomain"] = None, - secondary_endpoints: Optional["Endpoints"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + secondary_endpoints: Optional["_models.Endpoints"] = None, **kwargs ): """ @@ -299,10 +301,10 @@ def __init__( :keyword tags: A set of tags. Resource tags. :paramtype tags: dict[str, str] :keyword provisioning_state: The status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :paramtype provisioning_state: str or ~azure.mgmt.storage.v2015_06_15.models.ProvisioningState - :keyword account_type: The type of the storage account. Possible values include: - "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + :keyword account_type: The type of the storage account. Known values are: "Standard_LRS", + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :keyword primary_endpoints: The URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -311,7 +313,7 @@ def __init__( :keyword primary_location: The location of the primary data center for the storage account. :paramtype primary_location: str :keyword status_of_primary: The status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available", "Unavailable". :paramtype status_of_primary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :keyword last_geo_failover_time: The timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if @@ -323,7 +325,7 @@ def __init__( :paramtype secondary_location: str :keyword status_of_secondary: The status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available", "Unavailable". :paramtype status_of_secondary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :keyword creation_time: The creation date and time of the storage account in UTC. :paramtype creation_time: ~datetime.datetime @@ -402,7 +404,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar account_type: The sku name. Required for account creation; optional for update. Note that - in older versions, sku name was called accountType. Possible values include: "Standard_LRS", + in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType """ @@ -422,7 +424,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "AccountType"]] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, **kwargs ): """ @@ -437,8 +439,8 @@ def __init__( characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword account_type: The sku name. Required for account creation; optional for update. Note - that in older versions, sku name was called accountType. Possible values include: - "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + that in older versions, sku name was called accountType. Known values are: "Standard_LRS", + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType """ super(StorageAccountCreateParameters, self).__init__(**kwargs) @@ -493,7 +495,7 @@ class StorageAccountListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["StorageAccount"]] = None, + value: Optional[List["_models.StorageAccount"]] = None, **kwargs ): """ @@ -542,8 +544,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype tags: dict[str, str] :ivar account_type: The account type. Note that StandardZRS and PremiumLRS accounts cannot be changed to other account types, and other account types cannot be changed to StandardZRS or - PremiumLRS. Possible values include: "Standard_LRS", "Standard_ZRS", "Standard_GRS", - "Standard_RAGRS", "Premium_LRS". + PremiumLRS. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", + "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -561,8 +563,8 @@ def __init__( self, *, tags: Optional[Dict[str, str]] = None, - account_type: Optional[Union[str, "AccountType"]] = None, - custom_domain: Optional["CustomDomain"] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, **kwargs ): """ @@ -570,8 +572,8 @@ def __init__( :paramtype tags: dict[str, str] :keyword account_type: The account type. Note that StandardZRS and PremiumLRS accounts cannot be changed to other account types, and other account types cannot be changed to StandardZRS or - PremiumLRS. Possible values include: "Standard_LRS", "Standard_ZRS", "Standard_GRS", - "Standard_RAGRS", "Premium_LRS". + PremiumLRS. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", + "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -589,8 +591,8 @@ class Usage(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar unit: Required. The unit of measurement. Possible values include: "Count", "Bytes", - "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". + :ivar unit: Required. The unit of measurement. Known values are: "Count", "Bytes", "Seconds", + "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2015_06_15.models.UsageUnit :ivar current_value: Required. The current count of the allocated resources in the subscription. @@ -619,14 +621,14 @@ class Usage(msrest.serialization.Model): def __init__( self, *, - unit: Union[str, "UsageUnit"], + unit: Union[str, "_models.UsageUnit"], current_value: int, limit: int, - name: "UsageName", + name: "_models.UsageName", **kwargs ): """ - :keyword unit: Required. The unit of measurement. Possible values include: "Count", "Bytes", + :keyword unit: Required. The unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :paramtype unit: str or ~azure.mgmt.storage.v2015_06_15.models.UsageUnit :keyword current_value: Required. The current count of the allocated resources in the @@ -659,7 +661,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py index b275bafa3253..ad84ffb9fc1d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status indicating whether the primary location of the storage account is available or unavailable. """ @@ -19,7 +18,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class AccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -30,7 +29,7 @@ class AccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_RAGRS = "Standard_RAGRS" PREMIUM_LRS = "Premium_LRS" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the storage account at the time the operation was called. """ @@ -38,7 +37,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -46,7 +45,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py index 1903e9f75534..afdb471cc449 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2015-06-15" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2015-06-15" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2015-06-15" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,72 +337,73 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2015-06-15" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2015_06_15.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2015_06_15.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -398,31 +411,44 @@ def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -436,23 +462,28 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -460,14 +491,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -483,7 +521,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -491,9 +529,11 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -508,6 +548,9 @@ def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -521,35 +564,46 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, content_type=content_type, + 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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -558,13 +612,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -584,23 +637,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -610,7 +675,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -619,7 +684,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -636,23 +701,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -666,7 +743,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -674,9 +751,11 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -695,18 +774,24 @@ def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -714,14 +799,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -735,14 +827,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -753,29 +845,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -789,7 +892,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -802,14 +909,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -823,31 +930,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -861,7 +979,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -874,7 +996,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -882,7 +1004,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountKeys": + ) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -897,23 +1019,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -927,7 +1061,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -935,9 +1069,11 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccountKeys": + ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -950,18 +1086,24 @@ def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountKeys, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -969,14 +1111,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -990,5 +1139,5 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py index d6d112cbb9f8..f2ab11f7505c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2015-06-15" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2015_06_15.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2015_06_15.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Lists the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -90,29 +91,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +138,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,4 +155,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py index 73d28a412b43..0793f89e7467 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json index bda5a6a227b5..afc4507129f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py index e55fff2f886c..aad574519df6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -33,8 +34,11 @@ class StorageManagementClient: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -53,13 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py index 00c9b33ca782..a2ab4c7735c3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py index 4171e0334612..52cd6470accf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -34,8 +35,11 @@ class StorageManagementClient: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -54,8 +58,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py index 75df2fc0c534..e07812090f1a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_01_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -61,31 +61,44 @@ async def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +112,28 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +141,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +171,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +179,11 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -170,6 +197,9 @@ async def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -184,35 +214,46 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, content_type=content_type, + 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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -221,13 +262,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -246,23 +286,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -272,7 +324,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -281,7 +333,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -297,23 +349,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -327,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -335,9 +399,11 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -355,18 +421,24 @@ async def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -374,14 +446,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -395,14 +474,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -413,29 +492,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -449,7 +539,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -462,14 +556,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -482,31 +576,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -520,7 +625,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -533,7 +642,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -541,7 +650,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. @@ -555,23 +664,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -585,7 +706,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -593,9 +714,11 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. @@ -607,18 +730,24 @@ async def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -626,14 +755,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -647,5 +783,5 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py index c3df4e2711b6..bc052f8d67cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_01_01.aio.StorageManagementClient`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py index 9c86ce86ec79..d5c0bb50753c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py @@ -38,7 +38,9 @@ SkuTier, UsageUnit, ) - +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__ = [ 'CheckNameAvailabilityResult', 'CustomDomain', @@ -69,3 +71,5 @@ 'SkuTier', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py index 7e4597826a13..263bff8837ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py @@ -6,11 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class CheckNameAvailabilityResult(msrest.serialization.Model): @@ -23,7 +25,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2016_01_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -124,7 +126,7 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - services: Optional["EncryptionServices"] = None, + services: Optional["_models.EncryptionServices"] = None, **kwargs ): """ @@ -188,7 +190,7 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -303,11 +305,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2016_01_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2016_01_01.models.SkuTier """ @@ -324,12 +326,12 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2016_01_01.models.SkuName """ @@ -356,10 +358,10 @@ class StorageAccount(Resource): :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2016_01_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -368,7 +370,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available", "Unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2016_01_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -380,7 +382,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available", "Unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2016_01_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -394,7 +396,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ @@ -517,7 +519,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -538,7 +540,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): account encryption settings will remain the same. The default setting is unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ @@ -561,20 +563,20 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -594,7 +596,7 @@ def __init__( account encryption settings will remain the same. The default setting is unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ super(StorageAccountCreateParameters, self).__init__(**kwargs) @@ -616,8 +618,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "READ", "FULL". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "READ", "FULL". :vartype permissions: str or ~azure.mgmt.storage.v2016_01_01.models.KeyPermission """ @@ -750,7 +752,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ @@ -765,11 +767,11 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, **kwargs ): """ @@ -789,7 +791,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ super(StorageAccountUpdateParameters, self).__init__(**kwargs) @@ -805,7 +807,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2016_01_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -857,7 +859,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py index 1b64707c39ee..c81e944b487f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,21 +25,21 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "Available" UNAVAILABLE = "Unavailable" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "READ" FULL = "FULL" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required. Indicates the type of storage account. """ STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -48,7 +47,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -56,7 +55,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -67,14 +66,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py index 880e4d68fdef..b5fba128f4ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-01-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-01-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-01-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,72 +337,73 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-01-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_01_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -398,31 +411,44 @@ def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CheckNameAvailabilityResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -436,23 +462,28 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -460,14 +491,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -483,7 +521,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -491,9 +529,11 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -507,6 +547,9 @@ def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -520,35 +563,46 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, content_type=content_type, + 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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -557,13 +611,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -582,23 +635,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -608,7 +673,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -617,7 +682,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -633,23 +698,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -663,7 +740,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -671,9 +748,11 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -691,18 +770,24 @@ def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -710,14 +795,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -731,14 +823,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -749,29 +841,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -785,7 +888,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -798,14 +905,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -818,31 +925,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -856,7 +974,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -869,7 +991,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -877,7 +999,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. @@ -891,23 +1013,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -921,7 +1055,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -929,9 +1063,11 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: Optional[str] = "application/json", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. @@ -943,18 +1079,24 @@ def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters + :keyword content_type: Media type of the body sent to the API. Known values are: + "application/json" or "text/json". Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -962,14 +1104,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -983,5 +1132,5 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py index 72cd0e0d6e4d..9e0efa121dab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-01-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_01_01.StorageManagementClient`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -90,29 +91,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +138,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,4 +155,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py index b1e55270b061..7be55ff4bf05 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py index 1d0ba2cd56b5..aaf5119d6e5e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-12-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-12-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json index a412131b3500..1f0b375d5542 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"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\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py index e20cdb2b45a5..8dac5df1322d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementConfiguration @@ -33,8 +34,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -53,13 +57,17 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py index 95bb9e0d6b2c..36895a3e2a36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management import StorageManagement + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py index 4530a7716a3b..aa91ae19fe51 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2016-12-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2016-12-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py index d21dcc248666..cc2c0d6d2260 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementConfiguration @@ -34,8 +35,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2016-12-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -54,8 +58,12 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py index 25d69d4d554a..01d94dc2ef19 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_12_01.aio.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +326,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +343,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +385,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +393,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -364,13 +419,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +437,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +465,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +483,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +530,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +547,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +568,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +634,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +642,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +657,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +699,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +707,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -619,13 +727,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +745,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +773,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -662,9 +781,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -681,13 +800,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -695,14 +818,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -716,7 +846,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -724,9 +854,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -743,13 +873,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -757,14 +891,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -778,5 +919,5 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py index 5b1a91f62142..85a4db0fcfc0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_12_01.aio.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py index 4e47b256d7dc..02df7dd5ed2e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py @@ -48,7 +48,9 @@ SkuTier, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'CheckNameAvailabilityResult', @@ -89,3 +91,5 @@ 'SkuTier', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py index 74fc9ef657db..9c5a3946046b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,25 +22,25 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedServices :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedPermission :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -70,38 +72,37 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "AccountSasParametersSignedServices"], - resource_types: Union[str, "AccountSasParametersSignedResourceTypes"], - permissions: Union[str, "AccountSasParametersSignedPermission"], + services: Union[str, "_models.AccountSasParametersSignedServices"], + resource_types: Union[str, "_models.AccountSasParametersSignedResourceTypes"], + permissions: Union[str, "_models.AccountSasParametersSignedPermission"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedServices :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedPermission :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -132,7 +133,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2016_12_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -233,7 +234,7 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - services: Optional["EncryptionServices"] = None, + services: Optional["_models.EncryptionServices"] = None, **kwargs ): """ @@ -313,8 +314,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -488,18 +489,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2016_12_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -561,10 +561,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Union[str, "SignedResource"], - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Union[str, "_models.SignedResource"], + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -584,18 +584,18 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", - "c", "f", "s". + values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", + "s". :paramtype resource: str or ~azure.mgmt.storage.v2016_12_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -655,11 +655,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2016_12_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2016_12_01.models.SkuTier """ @@ -676,12 +676,12 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2016_12_01.models.SkuName """ @@ -708,10 +708,10 @@ class StorageAccount(Resource): :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2016_12_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -720,7 +720,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2016_12_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -732,7 +732,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2016_12_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -746,7 +746,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -877,7 +877,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -898,7 +898,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): account encryption settings will remain the same. The default setting is unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -924,21 +924,21 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -958,7 +958,7 @@ def __init__( account encryption settings will remain the same. The default setting is unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -984,8 +984,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.KeyPermission """ @@ -1118,7 +1118,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1136,11 +1136,11 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): @@ -1161,7 +1161,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1181,7 +1181,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2016_12_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -1233,7 +1233,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py index c59000b0d3cb..985e7c71ea53 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountSasParametersSignedPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountSasParametersSignedPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -32,7 +31,7 @@ class AccountSasParametersSignedPermission(with_metaclass(CaseInsensitiveEnumMet U = "u" P = "p" -class AccountSasParametersSignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountSasParametersSignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -42,7 +41,7 @@ class AccountSasParametersSignedResourceTypes(with_metaclass(CaseInsensitiveEnum C = "c" O = "o" -class AccountSasParametersSignedServices(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountSasParametersSignedServices(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -52,7 +51,7 @@ class AccountSasParametersSignedServices(with_metaclass(CaseInsensitiveEnumMeta, T = "t" F = "f" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -60,28 +59,28 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required. Indicates the type of storage account. """ STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -95,7 +94,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -103,7 +102,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -111,7 +110,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -121,7 +120,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -132,14 +131,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py index 291f880b1419..7df8399a811b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py @@ -9,7 +9,12 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +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__ = [ 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py index c3da1171d5ab..f41259e529b6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,39 +337,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -369,39 +382,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -413,72 +427,71 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2016-12-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_12_01.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -491,26 +504,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,23 +548,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -548,14 +576,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -571,7 +606,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -579,9 +614,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -609,35 +644,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -646,13 +693,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -672,23 +718,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -698,7 +756,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -707,7 +765,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -724,23 +782,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,7 +824,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +832,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -788,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -802,14 +876,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,14 +904,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -841,29 +922,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -877,7 +969,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,14 +986,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -911,31 +1007,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1056,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,7 +1073,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -970,7 +1081,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -985,23 +1096,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,7 +1138,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1023,9 +1146,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1043,13 +1166,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1057,14 +1184,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1212,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1086,9 +1220,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1105,13 +1239,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1119,14 +1257,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1140,7 +1285,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1148,9 +1293,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1167,13 +1312,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1181,14 +1330,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,5 +1358,5 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py index cb6a65936bb2..d8c69bf2f28f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2016-12-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2016_12_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2016_12_01.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -90,29 +91,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +138,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,4 +155,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py index b1e55270b061..7be55ff4bf05 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py index 67975f9a4bd9..6501569a624a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json index 06ff3b25e9b7..e071ed4ba882 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"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\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py index e928784b75fe..4fdfa964c3a5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementConfiguration @@ -37,8 +38,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -57,15 +61,23 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py index 95bb9e0d6b2c..36895a3e2a36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management import StorageManagement + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py index 75423496d596..cbccdf1a8846 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py index 9db018041360..9b9c92763004 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementConfiguration @@ -38,8 +39,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,10 +62,18 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py index 162b4acfdb68..de141c45187e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py index 2ab101b653be..059e14f909eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.aio.StorageManagement`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py index 2ee10b9cb7de..256fc3d160f2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.aio.StorageManagement`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py index c4deac383132..75c9c2cd1ff4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.aio.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-06-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +326,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +343,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +385,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +393,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -364,13 +419,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +437,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +465,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +483,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +530,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +547,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +568,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +634,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +642,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +657,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +699,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +707,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -619,13 +727,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +745,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +773,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -662,9 +781,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -681,13 +800,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -695,14 +818,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -716,7 +846,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -724,9 +854,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -743,13 +873,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -757,14 +891,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -778,5 +919,5 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py index 971abfc7f82c..824f2dc3e117 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.aio.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py index f43919086149..4ee274c194c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py @@ -66,7 +66,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'CheckNameAvailabilityResult', @@ -125,3 +127,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py index 27f9a8a68a2e..6c028a46d5b9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2017_06_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2017_06_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -126,7 +127,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2017_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -239,7 +240,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_06_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2017_06_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -259,16 +260,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2017_06_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2017_06_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -349,8 +350,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -625,7 +626,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -671,15 +672,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2017_06_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2017_06_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2017_06_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2017_06_01.models.DefaultAction """ @@ -697,17 +698,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2017_06_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -715,7 +716,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2017_06_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2017_06_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -749,9 +750,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -824,7 +825,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -902,7 +903,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2017_06_01.models.ReasonCode """ @@ -920,14 +921,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2017_06_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -944,18 +945,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1017,10 +1017,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Union[str, "SignedResource"], - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Union[str, "_models.SignedResource"], + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -1040,18 +1040,18 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", - "c", "f", "s". + values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", + "s". :paramtype resource: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1118,7 +1118,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -1138,16 +1138,15 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2017_06_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2017_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "BlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1182,13 +1181,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2017_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -1256,12 +1255,12 @@ class StorageAccount(Resource): :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2017_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1270,7 +1269,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2017_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1282,7 +1281,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2017_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1296,7 +1295,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1355,7 +1354,7 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): @@ -1438,7 +1437,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -1463,7 +1462,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2017_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1491,23 +1490,23 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -1531,7 +1530,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1559,8 +1558,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.KeyPermission """ @@ -1697,7 +1696,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1719,14 +1718,14 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -1748,7 +1747,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1799,7 +1798,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2017_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -1851,7 +1850,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -1905,7 +1904,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2017_06_01.models.State """ @@ -1925,7 +1924,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -1935,8 +1934,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2017_06_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py index f336ec50edb7..5802979735e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,28 +36,28 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -66,14 +65,14 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -87,7 +86,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -95,7 +94,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -103,7 +102,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -113,7 +112,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -123,7 +122,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -133,7 +132,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -143,7 +142,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -154,14 +153,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -171,7 +170,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py index 162b4acfdb68..de141c45187e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py @@ -11,9 +11,14 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py index 2cb1c4499173..2c251647d8f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.StorageManagement`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py index 9c7dc0062592..69e3e3e96457 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.StorageManagement`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py index 527d46eac815..da931aac0f06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,39 +337,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -369,39 +382,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -413,72 +427,71 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-06-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -491,26 +504,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,23 +548,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -548,14 +576,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -571,7 +606,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -579,9 +614,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -609,35 +644,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-06-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -646,13 +693,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -672,23 +718,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -698,7 +756,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -707,7 +765,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -724,23 +782,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,7 +824,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +832,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -788,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -802,14 +876,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,14 +904,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -841,29 +922,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -877,7 +969,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,14 +986,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -911,31 +1007,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1056,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,7 +1073,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -970,7 +1081,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -985,23 +1096,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,7 +1138,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1023,9 +1146,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1043,13 +1166,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1057,14 +1184,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1212,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1086,9 +1220,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1105,13 +1239,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1119,14 +1257,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1140,7 +1285,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1148,9 +1293,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1167,13 +1312,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1181,14 +1330,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,5 +1358,5 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py index 37c9cce9481d..f39c8ad5e632 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-06-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_06_01.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -90,29 +91,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +138,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,4 +155,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py index b1e55270b061..7be55ff4bf05 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py index ab09db68dd7a..f3081e971947 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json index 18c4818d73bb..3fb6ec0f3b28 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"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\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py index 84edc883b649..77054fa8a229 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementConfiguration @@ -37,8 +38,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -57,15 +61,23 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py index 95bb9e0d6b2c..36895a3e2a36 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management import StorageManagement + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagement'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py index 62905b5cff39..d381be1f70ce 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementConfiguration(Configuration): +class StorageManagementConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagement. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class StorageManagementConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft + Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2017-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +42,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2017-10-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +51,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2017-10-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py index 6a82295fa58a..2e9d63a3022f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementConfiguration @@ -38,8 +39,11 @@ class StorageManagement: :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2017-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,10 +62,18 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py index 162b4acfdb68..de141c45187e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py @@ -11,9 +11,14 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py index 7564699777bd..349fa83224c5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.aio.StorageManagement`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py index 54a0cee61607..62fd02ac34c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.aio.StorageManagement`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py index 34137157cf88..e68a6145f16b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.aio.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-10-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +326,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +343,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +385,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +393,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -364,13 +419,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +437,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +465,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +483,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +530,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +547,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +568,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +634,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +642,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +657,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +699,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +707,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -619,13 +727,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +745,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +773,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -662,9 +781,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -681,13 +800,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -695,14 +818,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -716,7 +846,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -724,9 +854,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -743,13 +873,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -757,14 +891,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -778,5 +919,5 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py index b0568aa54af2..92609f96cbd9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.aio.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,4 +120,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py index f43919086149..4ee274c194c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py @@ -66,7 +66,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'CheckNameAvailabilityResult', @@ -125,3 +127,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py index 4e51bdf007ea..325f86cf7b94 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2017_10_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2017_10_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -126,7 +127,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2017_10_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -239,7 +240,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_10_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2017_10_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -259,16 +260,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2017_10_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2017_10_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -349,8 +350,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -625,7 +626,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -671,15 +672,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2017_10_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2017_10_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2017_10_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2017_10_01.models.DefaultAction """ @@ -697,17 +698,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2017_10_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -715,7 +716,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2017_10_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2017_10_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -749,9 +750,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -824,7 +825,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -902,7 +903,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2017_10_01.models.ReasonCode """ @@ -920,14 +921,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2017_10_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -944,18 +945,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1017,10 +1017,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Union[str, "SignedResource"], - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Union[str, "_models.SignedResource"], + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -1040,18 +1040,18 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", - "c", "f", "s". + values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", + "s". :paramtype resource: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1118,7 +1118,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -1138,16 +1138,16 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2017_10_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2017_10_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1182,13 +1182,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2017_10_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -1256,12 +1256,12 @@ class StorageAccount(Resource): :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2017_10_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1270,7 +1270,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2017_10_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1282,7 +1282,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2017_10_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1296,7 +1296,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1355,7 +1355,7 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): @@ -1438,7 +1438,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -1463,7 +1463,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2017_10_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1491,23 +1491,23 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -1531,7 +1531,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_10_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1559,8 +1559,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.KeyPermission """ @@ -1690,7 +1690,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1700,7 +1700,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1723,15 +1723,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -1746,7 +1746,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1756,7 +1756,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1808,7 +1808,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2017_10_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -1860,7 +1860,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -1914,7 +1914,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2017_10_01.models.State """ @@ -1934,7 +1934,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -1944,8 +1944,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2017_10_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py index d02bb1744c31..3ecb508b75bd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,28 +36,28 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -66,7 +65,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -74,7 +73,7 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -88,7 +87,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -96,7 +95,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -104,7 +103,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -114,7 +113,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -124,7 +123,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -134,7 +133,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -144,7 +143,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -155,14 +154,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -172,7 +171,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py index 162b4acfdb68..de141c45187e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py @@ -11,9 +11,14 @@ from ._storage_accounts_operations import StorageAccountsOperations from ._usage_operations import UsageOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', 'StorageAccountsOperations', 'UsageOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py index 483aa53603fa..e75845cd0f52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.StorageManagement`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py index 6e35ddde351f..0ce92d5f7aed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.StorageManagement`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py index 2e8307ae2c8c..162ad06e0faa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,39 +337,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -369,39 +382,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -413,72 +427,71 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json, text/json") - api_version = "2017-10-01" - accept = "application/json, text/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.StorageManagement`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -491,26 +504,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,23 +548,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -548,14 +576,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -571,7 +606,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -579,9 +614,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -609,35 +644,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-10-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -646,13 +693,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -672,23 +718,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -698,7 +756,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -707,7 +765,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -724,23 +782,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,7 +824,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +832,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -788,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -802,14 +876,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,14 +904,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -841,29 +922,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -877,7 +969,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,14 +986,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -911,31 +1007,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1056,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,7 +1073,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -970,7 +1081,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -985,23 +1096,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,7 +1138,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1023,9 +1146,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1043,13 +1166,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1057,14 +1184,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1212,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1086,9 +1220,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1105,13 +1239,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1119,14 +1257,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1140,7 +1285,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1148,9 +1293,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1167,13 +1312,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1181,14 +1330,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,5 +1358,5 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py index 1713537c89a4..a3c5b39f680b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2017-10-01" - accept = "application/json, text/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + accept = _headers.pop('Accept', "application/json, text/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2017_10_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2017_10_01.StorageManagement`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -90,29 +91,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +138,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,4 +155,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py index 000f8a8fa02a..8db7df8cecb7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-02-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-02-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json index 139aa781ea20..3aecb678b570 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py index cad72c4b41d8..dc101a7829a4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -38,8 +39,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -58,16 +62,26 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py index 4753ba582e4f..46882474b47d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-02-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-02-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py index 362dd69b698c..3848c2fac697 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -40,8 +41,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,11 +64,21 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usage = UsageOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py index fd279979f158..09b0517d9606 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py @@ -12,6 +12,9 @@ from ._usage_operations import UsageOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -19,3 +22,5 @@ 'UsageOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py index f48caaa52136..3ad451cd79fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -66,23 +64,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async @@ -105,9 +115,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -131,13 +141,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -146,14 +160,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -167,7 +188,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -176,9 +197,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -201,13 +222,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -216,14 +241,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,7 +269,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -247,7 +279,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -267,11 +299,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -279,12 +316,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,11 +342,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -328,11 +372,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -340,12 +389,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,7 +411,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -364,9 +420,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -390,13 +446,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -405,14 +465,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,7 +493,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -435,9 +502,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -460,13 +527,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -475,14 +546,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -496,7 +574,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -506,9 +584,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -526,23 +604,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -554,15 +641,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -579,7 +674,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -590,7 +685,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -608,18 +703,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -627,13 +732,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -650,7 +763,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -661,7 +774,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -683,16 +796,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -700,13 +823,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -723,7 +854,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -734,7 +865,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -759,11 +890,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -771,13 +907,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -794,7 +937,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -804,9 +947,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -828,20 +971,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -853,15 +1000,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -878,7 +1032,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -887,9 +1041,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -905,20 +1059,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -930,14 +1088,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,5 +1116,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py index 14ccad1fdee1..efacb94f6e84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py index 449ca6e2634c..ec6a79836e0a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py index fac93bbe74ee..7925bc1115ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-02-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +326,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +343,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +385,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +393,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -364,13 +419,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +437,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +465,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +483,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +530,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +547,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +568,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +634,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +642,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +657,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +699,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +707,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -619,13 +727,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +745,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +773,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -662,9 +781,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -681,13 +800,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -695,14 +818,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -716,7 +846,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -724,9 +854,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -743,13 +873,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -757,14 +891,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -778,5 +919,5 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py index 525d91eb16e8..934beff80326 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsageOperations: - """UsageOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.aio.StorageManagementClient`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,14 +120,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -127,31 +139,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -165,7 +188,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,4 +205,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py index 7968a3f4625f..f38b411ec76d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py @@ -86,7 +86,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'AzureEntityResource', @@ -165,3 +167,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py index 4504b6849448..8b3f6431b892 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2018_02_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2018_02_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -212,18 +213,17 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -278,13 +278,13 @@ class BlobContainer(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -312,7 +312,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_02_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -425,7 +425,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_02_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2018_02_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -445,16 +445,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_02_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2018_02_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -535,8 +535,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -665,7 +665,7 @@ class ImmutabilityPolicy(AzureEntityResource): blobs in the container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyState """ @@ -716,7 +716,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyState """ @@ -837,8 +837,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -868,7 +868,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -877,7 +877,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1002,7 +1002,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -1057,18 +1057,17 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1123,13 +1122,13 @@ class ListContainerItem(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -1161,7 +1160,7 @@ class ListContainerItems(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ListContainerItem"]] = None, + value: Optional[List["_models.ListContainerItem"]] = None, **kwargs ): """ @@ -1241,7 +1240,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -1287,15 +1286,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_02_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_02_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_02_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2018_02_01.models.DefaultAction """ @@ -1313,17 +1312,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_02_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -1331,7 +1330,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_02_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2018_02_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -1365,9 +1364,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -1447,7 +1446,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -1471,7 +1470,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_02_01.models.ReasonCode """ @@ -1489,14 +1488,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_02_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -1513,17 +1512,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1584,10 +1583,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -1607,18 +1606,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1685,7 +1683,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -1705,16 +1703,16 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2018_02_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_02_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1749,13 +1747,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2018_02_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -1880,12 +1878,12 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_02_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1894,7 +1892,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_02_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1906,7 +1904,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_02_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1920,7 +1918,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1983,7 +1981,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_https_traffic_only: Optional[bool] = False, is_hns_enabled: Optional[bool] = False, **kwargs @@ -2069,7 +2067,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -2094,7 +2092,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_02_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2125,15 +2123,15 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, is_hns_enabled: Optional[bool] = False, **kwargs @@ -2141,8 +2139,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -2166,7 +2164,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_02_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2197,8 +2195,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.KeyPermission """ @@ -2328,7 +2326,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2338,7 +2336,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2361,15 +2359,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -2384,7 +2382,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2394,7 +2392,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2494,7 +2492,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -2548,7 +2546,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_02_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -2600,7 +2598,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -2654,7 +2652,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.State """ @@ -2674,7 +2672,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -2684,8 +2682,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_02_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py index 88318ccb431b..1f0605f3daa0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,28 +36,28 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -67,14 +66,14 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -82,7 +81,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -90,7 +89,7 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -100,7 +99,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -108,7 +107,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -118,14 +117,14 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -139,7 +138,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -147,7 +146,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -155,7 +154,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -163,7 +162,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -173,7 +172,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -183,7 +182,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -193,7 +192,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -203,7 +202,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -214,14 +213,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -231,7 +230,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py index fd279979f158..09b0517d9606 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py @@ -12,6 +12,9 @@ from ._usage_operations import UsageOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -19,3 +22,5 @@ 'UsageOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py index 10cc583ad191..4be56a391c64 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,16 +69,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,16 +116,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -130,23 +136,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -160,10 +164,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -171,21 +179,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -197,9 +203,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -207,16 +215,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -227,16 +234,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -244,23 +254,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,16 +281,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -290,23 +301,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -319,18 +328,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -339,25 +351,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,11 +383,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -386,23 +400,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -416,11 +428,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -429,22 +445,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -458,10 +472,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -469,22 +487,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -496,16 +512,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -513,24 +532,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -543,16 +560,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -560,49 +580,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -610,7 +626,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -626,23 +642,35 @@ def list( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,7 +684,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace @@ -665,9 +693,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -691,13 +719,17 @@ def create( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -706,14 +738,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -727,7 +766,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -736,9 +775,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -761,13 +800,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -776,14 +819,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -797,7 +847,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -807,7 +857,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -827,11 +877,16 @@ def get( :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -839,12 +894,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -858,11 +920,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -888,11 +950,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -900,12 +967,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -915,7 +989,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -924,9 +998,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -950,13 +1024,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -965,14 +1043,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -986,7 +1071,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -995,9 +1080,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1020,13 +1105,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1035,14 +1124,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1056,7 +1152,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1066,9 +1162,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1086,23 +1182,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1114,15 +1219,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,7 +1252,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1150,7 +1263,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1168,18 +1281,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1187,13 +1310,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1341,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1221,7 +1352,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -1243,16 +1374,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1260,13 +1401,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1283,7 +1432,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1294,7 +1443,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1319,11 +1468,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1331,13 +1485,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1354,7 +1515,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1364,9 +1525,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1388,20 +1549,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1413,15 +1578,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1438,7 +1610,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1447,9 +1619,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1465,20 +1637,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1490,14 +1666,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1511,5 +1694,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py index 696cc6a3b2e7..11955c7fb070 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py index 5f82f0c4a2c0..9244853ac254 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py index 41dde583407a..1f8bb1f6f859 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,39 +337,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -369,39 +382,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -413,72 +427,71 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -491,26 +504,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -524,23 +548,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -548,14 +576,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -571,7 +606,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -579,9 +614,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -609,35 +644,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-02-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -646,13 +693,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -672,23 +718,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -698,7 +756,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -707,7 +765,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -724,23 +782,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,7 +824,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +832,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -788,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -802,14 +876,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,14 +904,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -841,29 +922,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -877,7 +969,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,14 +986,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -911,31 +1007,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1056,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,7 +1073,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -970,7 +1081,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -985,23 +1096,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1015,7 +1138,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1023,9 +1146,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1043,13 +1166,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1057,14 +1184,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1212,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1086,9 +1220,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1105,13 +1239,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1119,14 +1257,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1140,7 +1285,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1148,9 +1293,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1167,13 +1312,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1181,14 +1330,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,5 +1358,5 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py index f36aaff8fb66..ea7384612a04 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -62,60 +65,60 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsageOperations(object): - """UsageOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsageOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_02_01.StorageManagementClient`'s + :attr:`usage` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -123,29 +126,40 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -159,7 +173,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,14 +190,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -190,31 +208,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -228,7 +257,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,4 +274,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py index 258189627fdb..e29149119f30 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json index 57bd56d7a830..345767c11ce0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py index 23c2bf1f1b23..8c60ecab1678 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -40,8 +41,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,16 +64,26 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py index edeb9aee8f38..5844901bbbb9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py index ba2dcab1ef40..597da0bd98cf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -40,8 +41,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,11 +64,21 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py index 56c6e236f63b..1582bc5faffe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py @@ -12,6 +12,9 @@ from ._usages_operations import UsagesOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -19,3 +22,5 @@ 'UsagesOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py index 38ff461e4a91..fe00ccde9cc4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -66,23 +64,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async @@ -105,9 +115,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -131,13 +141,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -146,14 +160,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -167,7 +188,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -176,9 +197,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -201,13 +222,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -216,14 +241,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,7 +269,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -247,7 +279,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -267,11 +299,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -279,12 +316,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,11 +342,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -328,11 +372,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -340,12 +389,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,7 +411,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -364,9 +420,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -390,13 +446,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -405,14 +465,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,7 +493,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -435,9 +502,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -460,13 +527,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -475,14 +546,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -496,7 +574,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -506,9 +584,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -526,23 +604,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -554,15 +641,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -579,7 +674,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -590,7 +685,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -608,18 +703,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -627,13 +732,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -650,7 +763,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -661,7 +774,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -683,16 +796,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -700,13 +823,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -723,7 +854,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -734,7 +865,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -759,11 +890,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -771,13 +907,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -794,7 +937,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -804,9 +947,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -828,20 +971,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -853,15 +1000,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -878,7 +1032,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -887,9 +1041,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -905,20 +1059,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -930,14 +1088,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,5 +1116,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py index 5f78fa9d0ca5..0e884daa8e95 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py index aaa32108fdd7..fde73fd4d189 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py index c80f2ac5904a..d1d235cb5328 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-03-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -283,7 +326,7 @@ async def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -300,23 +343,35 @@ async def get_properties( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,7 +385,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -338,9 +393,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -364,13 +419,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -378,14 +437,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -399,14 +465,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -417,29 +483,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +530,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -466,14 +547,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -487,31 +568,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -525,7 +617,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -538,7 +634,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -546,7 +642,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -561,23 +657,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -591,7 +699,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -599,9 +707,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -619,13 +727,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -633,14 +745,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +773,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -662,9 +781,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -681,13 +800,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -695,14 +818,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -716,7 +846,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -724,9 +854,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -743,13 +873,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -757,14 +891,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -778,7 +919,7 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore @distributed_trace_async @@ -788,7 +929,7 @@ async def get_management_policies( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -807,11 +948,16 @@ async def get_management_policies( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] request = build_get_management_policies_request( @@ -819,12 +965,19 @@ async def get_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -838,7 +991,7 @@ async def get_management_policies( return deserialized - get_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -847,9 +1000,9 @@ async def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPoliciesRulesSetParameter", + properties: _models.ManagementPoliciesRulesSetParameter, **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -871,13 +1024,17 @@ async def create_or_update_management_policies( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountManagementPolicies] _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') @@ -886,14 +1043,21 @@ async def create_or_update_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -907,11 +1071,11 @@ async def create_or_update_management_policies( return deserialized - create_or_update_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete_management_policies( + async def delete_management_policies( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -936,11 +1100,16 @@ async def delete_management_policies( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_management_policies_request( @@ -948,12 +1117,19 @@ async def delete_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -963,5 +1139,5 @@ async def delete_management_policies( if cls: return cls(pipeline_response, None, {}) - delete_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py index dfecb552b881..2c1a5b114ea1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,29 +56,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,7 +103,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -108,14 +120,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -127,31 +139,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -165,7 +188,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -178,4 +205,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py index 502feb60e149..dadf5bc3167b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py @@ -91,7 +91,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'AzureEntityResource', @@ -175,3 +177,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py index 1617b93056d4..be44fce7600d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,23 +22,23 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -68,36 +70,35 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -214,18 +215,17 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -280,13 +280,13 @@ class BlobContainer(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -314,7 +314,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -427,7 +427,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -448,16 +448,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -539,8 +539,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -669,7 +669,7 @@ class ImmutabilityPolicy(AzureEntityResource): blobs in the container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyState """ @@ -721,7 +721,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyState """ @@ -842,8 +842,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -874,7 +874,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -883,7 +883,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -1009,7 +1009,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -1064,18 +1064,17 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1130,13 +1129,13 @@ class ListContainerItem(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -1168,7 +1167,7 @@ class ListContainerItems(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ListContainerItem"]] = None, + value: Optional[List["_models.ListContainerItem"]] = None, **kwargs ): """ @@ -1302,7 +1301,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -1348,8 +1347,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: @@ -1357,7 +1356,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.DefaultAction """ @@ -1375,17 +1374,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -1393,7 +1392,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -1428,9 +1427,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -1511,7 +1510,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -1535,7 +1534,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ReasonCode """ @@ -1553,14 +1552,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -1577,17 +1576,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1648,10 +1647,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -1671,18 +1670,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1749,7 +1747,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -1769,16 +1767,16 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1813,13 +1811,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Possible values include: + update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -1944,12 +1942,12 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, @@ -1959,7 +1957,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1971,7 +1969,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. @@ -1986,7 +1984,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2049,7 +2047,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_https_traffic_only: Optional[bool] = False, is_hns_enabled: Optional[bool] = False, **kwargs @@ -2135,7 +2133,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the sku name. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -2160,7 +2158,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_03_01_preview.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2191,15 +2189,15 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, is_hns_enabled: Optional[bool] = False, **kwargs @@ -2207,8 +2205,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the sku name. :paramtype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -2232,7 +2230,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_03_01_preview.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2263,8 +2261,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeyPermission """ @@ -2481,7 +2479,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2491,7 +2489,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2514,15 +2512,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_https_traffic_only: Optional[bool] = False, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -2537,7 +2535,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2547,7 +2545,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2647,7 +2645,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -2702,7 +2700,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_03_01_preview.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -2754,7 +2752,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -2808,7 +2806,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.State """ @@ -2828,7 +2826,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -2838,8 +2836,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py index 3b47b1533b08..49d670df3480 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,28 +36,28 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -67,14 +66,14 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -82,7 +81,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -90,7 +89,7 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -100,7 +99,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -108,7 +107,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -118,18 +117,18 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -143,7 +142,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -151,7 +150,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -159,7 +158,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -167,7 +166,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -177,7 +176,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -187,7 +186,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -197,7 +196,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -207,7 +206,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. """ @@ -218,14 +217,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the sku tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -235,7 +234,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py index 56c6e236f63b..1582bc5faffe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py @@ -12,6 +12,9 @@ from ._usages_operations import UsagesOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -19,3 +22,5 @@ 'UsagesOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py index fdc8274544c3..c0b47a549ee9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,16 +69,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,16 +116,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -130,23 +136,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -160,10 +164,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -171,21 +179,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -197,9 +203,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -207,16 +215,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -227,16 +234,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -244,23 +254,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,16 +281,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -290,23 +301,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -319,18 +328,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -339,25 +351,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,11 +383,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -386,23 +400,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -416,11 +428,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -429,22 +445,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -458,10 +472,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -469,22 +487,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -496,16 +512,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -513,24 +532,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -543,16 +560,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -560,49 +580,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -610,7 +626,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -626,23 +642,35 @@ def list( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,7 +684,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace @@ -665,9 +693,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -691,13 +719,17 @@ def create( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -706,14 +738,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -727,7 +766,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -736,9 +775,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -761,13 +800,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -776,14 +819,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -797,7 +847,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -807,7 +857,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -827,11 +877,16 @@ def get( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -839,12 +894,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -858,11 +920,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -888,11 +950,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -900,12 +967,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -915,7 +989,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -924,9 +998,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -950,13 +1024,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -965,14 +1043,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -986,7 +1071,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -995,9 +1080,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1020,13 +1105,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1035,14 +1124,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1056,7 +1152,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1066,9 +1162,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1086,23 +1182,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1114,15 +1219,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,7 +1252,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1150,7 +1263,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1168,18 +1281,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1187,13 +1310,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1341,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1221,7 +1352,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -1243,16 +1374,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1260,13 +1401,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1283,7 +1432,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1294,7 +1443,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1319,11 +1468,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1331,13 +1485,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1354,7 +1515,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1364,9 +1525,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1388,20 +1549,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1413,15 +1578,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1438,7 +1610,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1447,9 +1619,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1465,20 +1637,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1490,14 +1666,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1511,5 +1694,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py index 06262a2db446..2a815c15da8c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py index b765bcd1572e..cf7ceb4cfe41 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py index 92b04b26792c..dd23bb54a4a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -148,31 +151,33 @@ def build_get_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -182,39 +187,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -225,29 +231,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -257,30 +265,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -291,31 +301,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -325,39 +337,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -369,39 +382,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -413,39 +427,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -459,10 +474,14 @@ def build_get_management_policies_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -470,21 +489,19 @@ def build_get_management_policies_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -495,16 +512,19 @@ def build_create_or_update_management_policies_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPoliciesRulesSetParameter] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -512,23 +532,21 @@ def build_create_or_update_management_policies_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -542,9 +560,11 @@ def build_delete_management_policies_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -552,47 +572,44 @@ def build_delete_management_policies_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -605,26 +622,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -638,23 +666,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -662,14 +694,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -685,7 +724,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -693,9 +732,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -724,35 +763,47 @@ def begin_create( ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-03-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -761,13 +812,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -787,23 +837,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -813,7 +875,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -822,7 +884,7 @@ def get_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -839,23 +901,35 @@ def get_properties( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -869,7 +943,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -877,9 +951,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -903,13 +977,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -917,14 +995,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -938,14 +1023,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -956,29 +1041,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -992,7 +1088,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1005,14 +1105,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1026,31 +1126,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1064,7 +1175,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1077,7 +1192,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1085,7 +1200,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1100,23 +1215,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1130,7 +1257,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1138,9 +1265,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1158,13 +1285,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1172,14 +1303,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1193,7 +1331,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1201,9 +1339,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1220,13 +1358,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1234,14 +1376,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1255,7 +1404,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1263,9 +1412,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1282,13 +1431,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1296,14 +1449,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1317,7 +1477,7 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore @distributed_trace @@ -1327,7 +1487,7 @@ def get_management_policies( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1346,11 +1506,16 @@ def get_management_policies( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] request = build_get_management_policies_request( @@ -1358,12 +1523,19 @@ def get_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1377,7 +1549,7 @@ def get_management_policies( return deserialized - get_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -1386,9 +1558,9 @@ def create_or_update_management_policies( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPoliciesRulesSetParameter", + properties: _models.ManagementPoliciesRulesSetParameter, **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1410,13 +1582,17 @@ def create_or_update_management_policies( :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountManagementPolicies] _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') @@ -1425,14 +1601,21 @@ def create_or_update_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create_or_update_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1446,11 +1629,11 @@ def create_or_update_management_policies( return deserialized - create_or_update_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete_management_policies( + def delete_management_policies( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1475,11 +1658,16 @@ def delete_management_policies( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_management_policies_request( @@ -1487,12 +1675,19 @@ def delete_management_policies( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete_management_policies.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1502,5 +1697,5 @@ def delete_management_policies( if cls: return cls(pipeline_response, None, {}) - delete_management_policies.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py index 95f9762d1a61..e65dc0e15e85 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -62,60 +65,60 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_03_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_03_01_preview.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -124,29 +127,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -160,7 +174,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,14 +191,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -192,31 +210,42 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -230,7 +259,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -243,4 +276,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py index 027df7375e6c..32d3d6129224 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json index 7f3524dbdbe5..050d16caa43a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py index a177d6653d3c..4596edc047a1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -43,7 +44,7 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -63,18 +64,32 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py index fe4c525e94d1..caa20f12ad8e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py index b76300387370..aeacc8c964fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -45,7 +46,7 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -65,13 +66,27 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py index c9129f68ae8f..fd06c8765f84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._blob_containers_operations import BlobContainersOperations from ._management_policies_operations import ManagementPoliciesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -23,3 +26,5 @@ 'BlobContainersOperations', 'ManagementPoliciesOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py index aa84be944156..1c63992c5a3a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -61,28 +59,43 @@ async def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +109,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async @@ -105,9 +118,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -126,18 +139,25 @@ async def create( :type container_name: str :param blob_container: Properties of the blob container to create. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -146,14 +166,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -167,7 +194,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -176,9 +203,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -196,18 +223,25 @@ async def update( :type container_name: str :param blob_container: Properties to update for the blob container. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -216,14 +250,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,7 +278,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -247,7 +288,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -262,16 +303,24 @@ async def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -279,12 +328,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -298,11 +354,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -323,16 +379,24 @@ async def delete( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -340,12 +404,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,7 +426,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -364,9 +435,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -385,18 +456,25 @@ async def set_legal_hold( :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LegalHold, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -405,14 +483,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -426,7 +511,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -435,9 +520,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -455,18 +540,25 @@ async def clear_legal_hold( :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LegalHold, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -475,14 +567,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -496,7 +595,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -506,9 +605,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -526,23 +625,35 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -554,15 +665,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -579,7 +698,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -590,7 +709,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -608,18 +727,31 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -627,13 +759,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -650,7 +790,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -661,7 +801,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -683,16 +823,29 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -700,13 +853,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -723,7 +884,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -734,7 +895,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -754,16 +915,24 @@ async def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -771,13 +940,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -794,7 +970,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -804,9 +980,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -828,20 +1004,27 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -853,15 +1036,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -878,7 +1068,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -887,9 +1077,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -905,20 +1095,27 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -930,14 +1127,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,5 +1155,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py index bb77d1ea4a29..737a7a5cd0d7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,35 +23,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -65,18 +63,30 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -84,14 +94,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +123,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -114,7 +132,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -125,28 +143,49 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,5 +199,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py index 8199f2dd6d7a..dd2859ba24d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,16 +63,24 @@ async def get( always be 'default'. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] request = build_get_request( @@ -82,12 +88,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPoliciesRulesSetParameter", + properties: _models.ManagementPoliciesRulesSetParameter, **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -128,18 +141,25 @@ async def create_or_update( ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountManagementPolicies] _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') @@ -148,14 +168,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +196,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -193,16 +220,24 @@ async def delete( always be 'default'. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +245,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +267,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py index 32cf2b704583..ad1f75f2f960 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,61 +24,73 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py index 61360cf1c6dc..63d8c62e76a4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,34 +24,35 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageSkuListResult or the result of cls(response) @@ -60,29 +60,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +107,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +124,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py index 3895931d3a31..23084450be25 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -61,31 +59,45 @@ async def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +111,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +139,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +169,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +177,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -171,6 +194,9 @@ async def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -185,35 +211,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-07-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +260,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -243,28 +280,43 @@ async def delete( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +326,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +336,7 @@ async def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +350,46 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +403,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +411,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -365,18 +432,25 @@ async def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +458,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,17 +486,20 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) @@ -423,29 +507,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +554,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,20 +571,23 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) @@ -493,31 +595,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +644,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +661,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -552,7 +669,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -562,28 +679,43 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -597,7 +729,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -605,9 +737,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -620,18 +752,25 @@ async def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -639,14 +778,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -660,7 +806,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -668,9 +814,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -682,18 +828,25 @@ async def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListAccountSasResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -701,14 +854,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,7 +882,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -730,9 +890,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -744,18 +904,25 @@ async def list_service_sas( :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListServiceSasResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -763,14 +930,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -784,32 +958,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -819,11 +1005,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -840,6 +1026,9 @@ async def begin_failover( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :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 @@ -852,18 +1041,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +1069,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -883,7 +1085,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py index 08c9560de9ad..09be6a0be022 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,69 +24,81 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. :param location: The location of the Azure Storage resource. :type location: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +129,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py index 8b38101cbc31..05d8a2809ffe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py @@ -98,7 +98,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'AzureEntityResource', @@ -189,3 +191,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py index faa5d60322eb..e9b8ee86582e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2018_07_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2018_07_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -212,18 +213,17 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -278,13 +278,13 @@ class BlobContainer(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -345,9 +345,9 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, **kwargs ): """ @@ -379,7 +379,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_07_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -453,7 +453,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -500,7 +500,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -632,7 +632,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_07_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2018_07_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -652,16 +652,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_07_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2018_07_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -742,8 +742,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -820,8 +820,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -918,7 +917,7 @@ class ImmutabilityPolicy(AzureEntityResource): blobs in the container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyState """ @@ -969,7 +968,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyState """ @@ -1090,8 +1089,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1121,7 +1120,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -1130,7 +1129,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1255,7 +1254,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -1310,18 +1309,17 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1376,13 +1374,13 @@ class ListContainerItem(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -1414,7 +1412,7 @@ class ListContainerItems(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ListContainerItem"]] = None, + value: Optional[List["_models.ListContainerItem"]] = None, **kwargs ): """ @@ -1548,7 +1546,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -1594,15 +1592,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_07_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_07_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_07_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2018_07_01.models.DefaultAction """ @@ -1620,17 +1618,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_07_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -1638,7 +1636,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_07_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2018_07_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -1672,9 +1670,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -1754,7 +1752,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -1778,7 +1776,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_07_01.models.ReasonCode """ @@ -1796,14 +1794,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_07_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -1820,17 +1818,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1891,10 +1889,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -1914,18 +1912,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1992,7 +1989,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -2012,16 +2009,16 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". :vartype name: str or ~azure.mgmt.storage.v2018_07_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_07_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2056,13 +2053,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". :paramtype name: str or ~azure.mgmt.storage.v2018_07_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -2187,13 +2184,13 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_07_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -2202,7 +2199,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_07_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -2214,7 +2211,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_07_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -2228,7 +2225,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2304,7 +2301,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, @@ -2397,7 +2394,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -2422,7 +2419,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_07_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2457,15 +2454,15 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, @@ -2474,8 +2471,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -2499,7 +2496,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_07_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2534,8 +2531,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.KeyPermission """ @@ -2752,8 +2749,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2763,7 +2760,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2790,16 +2787,16 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -2815,8 +2812,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2826,7 +2823,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2930,7 +2927,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -2984,7 +2981,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_07_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -3036,7 +3033,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -3090,7 +3087,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.State """ @@ -3110,7 +3107,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -3120,8 +3117,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_07_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py index f9d371f333e0..10bd237deace 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,7 +36,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -47,14 +46,14 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -66,21 +65,21 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -89,14 +88,14 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -104,7 +103,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -114,7 +113,7 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -124,7 +123,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -132,7 +131,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -142,18 +141,18 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -167,7 +166,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -175,7 +174,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -183,7 +182,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -191,7 +190,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -201,7 +200,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -211,7 +210,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -221,7 +220,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -231,7 +230,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -243,14 +242,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_LRS = "Premium_LRS" PREMIUM_ZRS = "Premium_ZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -260,7 +259,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py index c9129f68ae8f..fd06c8765f84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py @@ -14,6 +14,9 @@ from ._blob_containers_operations import BlobContainersOperations from ._management_policies_operations import ManagementPoliciesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -23,3 +26,5 @@ 'BlobContainersOperations', 'ManagementPoliciesOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py index 10b9fc1d7be1..a42968de2055 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,16 +69,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,16 +116,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -130,23 +136,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -160,10 +164,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -171,21 +179,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -197,9 +203,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -207,16 +215,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -227,16 +234,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -244,23 +254,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,16 +281,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -290,23 +301,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -319,18 +328,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -339,25 +351,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,11 +383,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -386,23 +400,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -416,11 +428,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -429,22 +445,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -458,10 +472,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -469,22 +487,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -496,16 +512,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -513,24 +532,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -543,16 +560,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -560,49 +580,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -610,7 +626,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -621,28 +637,43 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListContainerItems, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,7 +687,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace @@ -665,9 +696,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -686,18 +717,25 @@ def create( :type container_name: str :param blob_container: Properties of the blob container to create. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -706,14 +744,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -727,7 +772,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -736,9 +781,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -756,18 +801,25 @@ def update( :type container_name: str :param blob_container: Properties to update for the blob container. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -776,14 +828,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -797,7 +856,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -807,7 +866,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -822,16 +881,24 @@ def get( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobContainer, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -839,12 +906,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -858,11 +932,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -883,16 +957,24 @@ def delete( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -900,12 +982,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -915,7 +1004,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -924,9 +1013,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -945,18 +1034,25 @@ def set_legal_hold( :type container_name: str :param legal_hold: The LegalHold property that will be set to a blob container. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LegalHold, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -965,14 +1061,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -986,7 +1089,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -995,9 +1098,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1015,18 +1118,25 @@ def clear_legal_hold( :type container_name: str :param legal_hold: The LegalHold property that will be clear from a blob container. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LegalHold, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1035,14 +1145,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1056,7 +1173,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1066,9 +1183,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1086,23 +1203,35 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1114,15 +1243,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1139,7 +1276,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1150,7 +1287,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1168,18 +1305,31 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1187,13 +1337,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1368,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1221,7 +1379,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -1243,16 +1401,29 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1260,13 +1431,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1283,7 +1462,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1294,7 +1473,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1314,16 +1493,24 @@ def lock_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1331,13 +1518,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1354,7 +1548,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1364,9 +1558,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1388,20 +1582,27 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1413,15 +1614,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1438,7 +1646,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1447,9 +1655,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1465,20 +1673,27 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1490,14 +1705,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1511,5 +1733,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py index 44dea58a50b5..56bee2c58b7f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,17 +31,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -49,23 +52,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,11 +79,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -90,54 +95,50 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -151,18 +152,30 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -170,14 +183,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -191,7 +212,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -200,7 +221,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -211,28 +232,49 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,5 +288,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py index a955f9e00034..60038da9ae60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPoliciesRulesSetParameter] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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 = "2018-03-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-03-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -182,16 +184,24 @@ def get( always be 'default'. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] request = build_get_request( @@ -199,12 +209,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +235,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +244,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPoliciesRulesSetParameter", + properties: _models.ManagementPoliciesRulesSetParameter, **kwargs: Any - ) -> "_models.StorageAccountManagementPolicies": + ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -245,18 +262,25 @@ def create_or_update( ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName :param properties: The data policy rules to set to a storage account. :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountManagementPolicies, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountManagementPolicies"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-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.StorageAccountManagementPolicies] _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') @@ -265,14 +289,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +317,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -310,16 +341,24 @@ def delete( always be 'default'. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-03-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +366,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +388,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py index bd46ae9ac90f..31c83c0961d2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,83 +30,97 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :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.storage.v2018_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +134,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +151,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py index ee61bf4d6ccb..355b041f6f3a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,61 +31,64 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageSkuListResult or the result of cls(response) @@ -92,29 +96,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +143,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +160,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py index 2f3c34d0e6ac..d9e1c1d4de56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[str] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -295,31 +305,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -329,39 +341,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,39 +386,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -417,39 +431,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-07-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -462,56 +477,55 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -519,31 +533,45 @@ def check_name_availability( lower-case letters only. :type account_name: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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.storage.v2018_07_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -557,23 +585,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -581,14 +613,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -604,7 +643,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -612,9 +651,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -629,6 +668,9 @@ def begin_create( :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :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 @@ -642,35 +684,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-07-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -679,13 +733,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -700,28 +753,43 @@ def delete( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -731,7 +799,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -741,7 +809,7 @@ def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -755,31 +823,46 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -793,7 +876,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -801,9 +884,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -822,18 +905,25 @@ def update( :type account_name: str :param parameters: The parameters to provide for the updated account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -841,14 +931,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -862,17 +959,20 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) @@ -880,29 +980,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -916,7 +1027,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -929,20 +1044,23 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. :type resource_group_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either StorageAccountListResult or the result of cls(response) @@ -950,31 +1068,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -988,7 +1117,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1001,7 +1134,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1009,7 +1142,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1019,28 +1152,43 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1054,7 +1202,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1062,9 +1210,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1077,18 +1225,25 @@ def regenerate_key( :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. :type regenerate_key: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1096,14 +1251,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1117,7 +1279,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1125,9 +1287,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1139,18 +1301,25 @@ def list_account_sas( :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListAccountSasResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1158,14 +1327,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1179,7 +1355,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1187,9 +1363,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1201,18 +1377,25 @@ def list_service_sas( :type account_name: str :param parameters: The parameters to provide to list service SAS credentials. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ListServiceSasResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1220,14 +1403,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1241,32 +1431,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1276,11 +1478,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1297,6 +1499,9 @@ def begin_failover( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :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 @@ -1309,18 +1514,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1330,8 +1542,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1340,7 +1558,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py index 18dc70af1d03..5f3c3319832a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,96 +32,110 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-07-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_07_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_07_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. :param location: The location of the Azure Storage resource. :type location: str + :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either UsageListResult or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +149,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +166,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py index e210f7d63839..2a7935dedc39 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-11-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json index da90b392297c..821c231c15bc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py index 3bc34e0e6c83..d3bba021f989 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -43,8 +44,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -63,18 +67,32 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py index 46883bec2cf5..e8af14a2ebe8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-11-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-11-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py index dfcd9c84d5f2..6dc3d35a14ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -45,8 +46,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2018-11-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -65,13 +69,27 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py index b6aa35800a96..4d4295e47e06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py @@ -14,6 +14,9 @@ from ._blob_services_operations import BlobServicesOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -23,3 +26,5 @@ 'BlobServicesOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py index 20354f48e01d..1b4007691a40 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -66,23 +64,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async @@ -105,9 +115,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -131,13 +141,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -146,14 +160,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -171,7 +192,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -180,9 +201,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -205,13 +226,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -220,14 +245,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,7 +273,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -251,7 +283,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -271,11 +303,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -283,12 +320,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,11 +346,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -332,11 +376,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -344,12 +393,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -359,7 +415,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -368,9 +424,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -394,13 +450,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -409,14 +469,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -430,7 +497,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -439,9 +506,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -464,13 +531,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -479,14 +550,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -500,7 +578,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -510,9 +588,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -530,23 +608,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -558,15 +645,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -583,7 +678,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -594,7 +689,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -612,18 +707,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -631,13 +736,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,7 +767,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -665,7 +778,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -687,16 +800,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -704,13 +827,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -727,7 +858,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -738,7 +869,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -763,11 +894,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -775,13 +911,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -798,7 +941,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -808,9 +951,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -832,20 +975,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -857,15 +1004,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -882,7 +1036,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -891,9 +1045,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -909,20 +1063,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -934,14 +1092,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -955,5 +1120,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py index 10a61fd2e118..3b62ce6b0dba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,35 +23,33 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -65,18 +63,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -84,14 +91,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -105,7 +120,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -114,7 +129,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -125,28 +140,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -160,5 +193,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py index 557bbd26ac15..324761d824ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py index 9f26fc42e81d..a0587349cf60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py index 96993efcddcf..4ae0541a8198 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py index b50f8b6b2f8b..d8ce40438942 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -552,7 +648,7 @@ async def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -567,23 +663,35 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -597,7 +705,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -605,9 +713,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -625,13 +733,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -639,14 +751,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -660,7 +779,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -668,9 +787,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -687,13 +806,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -701,14 +824,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,7 +852,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -730,9 +860,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -749,13 +879,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -763,14 +897,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -784,32 +925,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -819,11 +972,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -852,18 +1005,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -873,8 +1033,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -883,13 +1049,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -909,23 +1074,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -935,5 +1112,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py index 457c302cca05..f76e7817ea70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py index 400ba7241c71..85d8f76f4325 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py @@ -105,7 +105,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'AzureEntityResource', @@ -203,3 +205,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py index f60fbdc8f96b..eaf95925e8da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2018_11_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2018_11_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -212,18 +213,17 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -278,13 +278,13 @@ class BlobContainer(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -345,9 +345,9 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, **kwargs ): """ @@ -379,7 +379,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_11_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -453,7 +453,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -500,7 +500,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -698,7 +698,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_11_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2018_11_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -718,16 +718,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_11_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2018_11_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -808,8 +808,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -886,8 +886,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2018_11_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -984,7 +983,7 @@ class ImmutabilityPolicy(AzureEntityResource): blobs in the container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyState """ @@ -1035,7 +1034,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyState """ @@ -1156,8 +1155,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1187,7 +1186,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -1196,7 +1195,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1321,7 +1320,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -1376,18 +1375,17 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1442,13 +1440,13 @@ class ListContainerItem(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -1480,7 +1478,7 @@ class ListContainerItems(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ListContainerItem"]] = None, + value: Optional[List["_models.ListContainerItem"]] = None, **kwargs ): """ @@ -1556,7 +1554,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -1586,8 +1584,8 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, **kwargs ): """ @@ -1623,9 +1621,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, **kwargs ): """ @@ -1667,8 +1665,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -1730,7 +1728,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2018_11_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyDefinition @@ -1753,8 +1751,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -1764,7 +1762,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2018_11_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyDefinition @@ -1797,7 +1795,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -1823,7 +1821,7 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - delete: Optional["DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -1876,7 +1874,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -1922,15 +1920,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_11_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_11_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_11_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2018_11_01.models.DefaultAction """ @@ -1948,17 +1946,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_11_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -1966,7 +1964,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_11_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2018_11_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -2000,9 +1998,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -2082,7 +2080,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -2106,7 +2104,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_11_01.models.ReasonCode """ @@ -2124,14 +2122,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_11_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -2148,17 +2146,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -2219,10 +2217,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -2242,18 +2240,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -2320,7 +2317,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -2340,16 +2337,16 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". :vartype name: str or ~azure.mgmt.storage.v2018_11_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_11_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2384,13 +2381,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". :paramtype name: str or ~azure.mgmt.storage.v2018_11_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -2515,13 +2512,13 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_11_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -2530,7 +2527,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_11_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -2542,7 +2539,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_11_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -2556,7 +2553,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2632,7 +2629,7 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, + identity: Optional["_models.Identity"] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, @@ -2725,7 +2722,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -2750,7 +2747,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_11_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2785,15 +2782,15 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, @@ -2802,8 +2799,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -2827,7 +2824,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_11_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2862,8 +2859,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.KeyPermission """ @@ -2993,8 +2990,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3004,7 +3001,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -3031,16 +3028,16 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, enable_azure_files_aad_integration: Optional[bool] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): """ @@ -3056,8 +3053,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3067,7 +3064,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -3171,7 +3168,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -3225,7 +3222,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_11_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -3277,7 +3274,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -3331,7 +3328,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.State """ @@ -3351,7 +3348,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -3361,8 +3358,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_11_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py index f4520a5730d4..895e7f2b2388 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,7 +36,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -47,14 +46,14 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -66,21 +65,21 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -89,14 +88,14 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -104,7 +103,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -114,7 +113,7 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -124,7 +123,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -132,7 +131,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -142,18 +141,18 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -167,7 +166,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -175,7 +174,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -183,7 +182,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -191,7 +190,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -201,13 +200,13 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -217,7 +216,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -227,7 +226,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -237,7 +236,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -249,14 +248,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PREMIUM_LRS = "Premium_LRS" PREMIUM_ZRS = "Premium_ZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -266,7 +265,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py index b6aa35800a96..4d4295e47e06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py @@ -14,6 +14,9 @@ from ._blob_services_operations import BlobServicesOperations from ._blob_containers_operations import BlobContainersOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -23,3 +26,5 @@ 'BlobServicesOperations', 'BlobContainersOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py index 433c07e2f44a..0f3d31dae7bb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,16 +69,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,16 +116,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -130,23 +136,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -160,10 +164,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -171,21 +179,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -197,9 +203,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -207,16 +215,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -227,16 +234,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -244,23 +254,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -273,16 +281,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -290,23 +301,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -319,18 +328,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -339,25 +351,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,11 +383,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -386,23 +400,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -416,11 +428,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -429,22 +445,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -458,10 +472,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -469,22 +487,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -496,16 +512,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -513,24 +532,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -543,16 +560,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -560,49 +580,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -610,7 +626,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListContainerItems": + ) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -626,23 +642,35 @@ def list( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -656,7 +684,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace @@ -665,9 +693,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -691,13 +719,17 @@ def create( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -706,14 +738,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -731,7 +770,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -740,9 +779,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -765,13 +804,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -780,14 +823,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -801,7 +851,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -811,7 +861,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -831,11 +881,16 @@ def get( :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -843,12 +898,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -862,11 +924,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -892,11 +954,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -904,12 +971,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -919,7 +993,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -928,9 +1002,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -954,13 +1028,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -969,14 +1047,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -990,7 +1075,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -999,9 +1084,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1024,13 +1109,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1039,14 +1128,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1060,7 +1156,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1070,9 +1166,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1090,23 +1186,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1118,15 +1223,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1143,7 +1256,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1154,7 +1267,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1172,18 +1285,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1191,13 +1314,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1214,7 +1345,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1225,7 +1356,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -1247,16 +1378,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1264,13 +1405,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1287,7 +1436,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1298,7 +1447,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1323,11 +1472,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1335,13 +1489,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1358,7 +1519,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1368,9 +1529,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1392,20 +1553,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1417,15 +1582,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1442,7 +1614,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1451,9 +1623,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1469,20 +1641,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1494,14 +1670,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1515,5 +1698,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py index d0b7699a81b0..3ad1c0edfe7d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,17 +31,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2018-11-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -49,23 +52,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -78,11 +79,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -90,54 +95,50 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -151,18 +152,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -170,14 +180,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -191,7 +209,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -200,7 +218,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -211,28 +229,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,5 +282,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py index a1d762224250..4f44fe3159aa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py index 3eb2331f155f..7447d5b49380 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py index aaf92c328e39..79e112ac373e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py index b56a305437a8..4aaa29d1b6be 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[str] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -295,31 +305,33 @@ def build_list_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -329,39 +341,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -373,39 +386,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -417,39 +431,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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 = "2018-11-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -462,25 +477,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -491,56 +507,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -553,26 +568,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -586,23 +612,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -610,14 +640,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -633,7 +670,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -641,9 +678,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -671,35 +708,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_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-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -708,13 +757,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -734,23 +782,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -760,7 +820,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -770,7 +830,7 @@ def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -784,31 +844,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -822,7 +894,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -830,9 +902,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -856,13 +928,17 @@ def update( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -870,14 +946,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -891,14 +974,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -909,29 +992,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -945,7 +1039,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -958,14 +1056,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -979,31 +1077,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1017,7 +1126,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1030,7 +1143,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1038,7 +1151,7 @@ def list_keys( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1053,23 +1166,35 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1083,7 +1208,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1091,9 +1216,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1111,13 +1236,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1125,14 +1254,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1146,7 +1282,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1154,9 +1290,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1173,13 +1309,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1187,14 +1327,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1208,7 +1355,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1216,9 +1363,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1235,13 +1382,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1249,14 +1400,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1270,32 +1428,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1305,11 +1475,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1338,18 +1508,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1359,8 +1536,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1369,13 +1552,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1395,23 +1577,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) 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-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1421,5 +1615,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py index 68bab2805616..40ce19e78634 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2018-11-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2018_11_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2018_11_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py index 15c25a75bf29..d997826051ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json index 6e4b0d7dd7e1..14326d881fac 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py index e8d696cdc673..a0f640c8db22 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -47,8 +48,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,20 +71,38 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py index 9b0baac5d7cd..a72047cbad2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py index d2bb1d9cf954..3ce1382f61f5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -49,8 +50,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -69,15 +73,33 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py index f6f55e8dcfc9..12917503aa75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py @@ -16,6 +16,9 @@ from ._file_services_operations import FileServicesOperations from ._file_shares_operations import FileSharesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -27,3 +30,5 @@ 'FileServicesOperations', 'FileSharesOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py index df92bd141852..f52b68e39263 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -66,13 +64,13 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param skip_token: Optional. Continuation token for the list operation. + :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -80,11 +78,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +160,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -173,13 +186,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -188,14 +205,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +237,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -222,9 +246,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -247,13 +271,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -262,14 +290,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +318,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -293,7 +328,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,11 +348,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -325,12 +365,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,11 +391,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -374,11 +421,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -386,12 +438,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -401,7 +460,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -410,9 +469,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -436,13 +495,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -451,14 +514,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +542,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -481,9 +551,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -506,13 +576,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -521,14 +595,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +623,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -552,9 +633,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -572,23 +653,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -600,15 +690,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -625,7 +723,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -636,7 +734,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -654,18 +752,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -673,13 +781,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,7 +812,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -707,7 +823,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -729,16 +845,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -746,13 +872,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -769,7 +903,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -780,7 +914,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -805,11 +939,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -817,13 +956,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -840,7 +986,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -850,9 +996,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -874,20 +1020,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -899,15 +1049,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -924,7 +1081,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -933,9 +1090,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -951,20 +1108,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -976,14 +1137,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,5 +1165,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py index 9b9a19b38713..b31f94456a7f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py index a87dce3a231b..778aaff67642 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py index cdb1f4575bba..41ffb6148170 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,13 +63,13 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param skip_token: Optional. Continuation token for the list operation. + :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -79,11 +77,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +94,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +111,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +134,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +151,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -146,9 +159,9 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -172,13 +185,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -187,14 +204,21 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -212,7 +236,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -221,9 +245,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -246,13 +270,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -261,14 +289,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +317,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -292,7 +327,7 @@ async def get( account_name: str, share_name: str, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -312,11 +347,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -324,12 +364,19 @@ async def get( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -343,11 +390,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -373,11 +420,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -385,12 +437,19 @@ async def delete( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -400,5 +459,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py index 1c282345d7c3..b8e776d6caed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py index 8cc150105969..137bad1d503b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py index 260d736d83bd..ace3770fecfe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py index 7991466668f9..402191332716 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,13 +1056,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -916,23 +1081,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -942,5 +1119,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py index 5b337768b066..dcc371d56952 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py index 39bc5b401be6..ff69ee353850 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py @@ -118,7 +118,9 @@ State, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'ActiveDirectoryProperties', @@ -229,3 +231,5 @@ 'State', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py index b15703ea8ec0..b023f8cecd18 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -20,22 +22,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2019_04_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -67,35 +69,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2019_04_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -275,8 +276,8 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2019_04_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -296,13 +297,13 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2019_04_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -330,18 +331,17 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -396,13 +396,13 @@ class BlobContainer(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -496,11 +496,11 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, **kwargs ): """ @@ -563,7 +563,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2019_04_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -623,7 +623,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -689,7 +689,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -736,7 +736,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -934,7 +934,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_04_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2019_04_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. @@ -954,16 +954,16 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2019_04_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2019_04_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. @@ -1044,8 +1044,8 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -1175,7 +1175,7 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -1356,8 +1356,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2019_04_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -1454,7 +1453,7 @@ class ImmutabilityPolicy(AzureEntityResource): blobs in the container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyState """ @@ -1505,7 +1504,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyState """ @@ -1626,8 +1625,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1657,7 +1656,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -1666,7 +1665,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1791,7 +1790,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -1846,18 +1845,17 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1912,13 +1910,13 @@ class ListContainerItem(AzureEntityResource): def __init__( self, *, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -2034,7 +2032,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -2064,8 +2062,8 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, **kwargs ): """ @@ -2101,9 +2099,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, **kwargs ): """ @@ -2145,8 +2143,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -2208,7 +2206,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2019_04_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyDefinition @@ -2231,8 +2229,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -2242,7 +2240,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2019_04_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyDefinition @@ -2275,7 +2273,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -2301,7 +2299,7 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - delete: Optional["DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -2354,7 +2352,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -2400,15 +2398,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2019_04_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2019_04_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2019_04_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2019_04_01.models.DefaultAction """ @@ -2426,17 +2424,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2019_04_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -2444,7 +2442,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2019_04_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2019_04_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -2478,9 +2476,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -2560,7 +2558,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -2584,7 +2582,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2019_04_01.models.ReasonCode """ @@ -2602,14 +2600,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2019_04_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -2626,17 +2624,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -2697,10 +2695,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -2720,18 +2718,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -2798,7 +2795,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -2818,17 +2815,17 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_04_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Possible values include: - "Standard", "Premium". + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_04_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2863,13 +2860,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Possible values include: + update. Note that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_04_01.models.SkuName @@ -2995,13 +2992,13 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_04_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -3010,7 +3007,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2019_04_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -3022,7 +3019,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2019_04_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -3036,7 +3033,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3054,15 +3051,15 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3133,13 +3130,13 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -3160,15 +3157,15 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3251,7 +3248,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -3276,7 +3273,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3288,15 +3285,15 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3333,29 +3330,29 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -3379,7 +3376,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3391,15 +3388,15 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3435,8 +3432,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.KeyPermission """ @@ -3572,8 +3569,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3583,7 +3580,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3594,15 +3591,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3631,19 +3628,19 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -3660,8 +3657,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3671,7 +3668,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3683,15 +3680,15 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3796,7 +3793,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -3850,7 +3847,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2019_04_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -3902,7 +3899,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -3956,7 +3953,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.State """ @@ -3976,7 +3973,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -3986,8 +3983,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2019_04_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py index 4b237ba27fc4..85dc99f0210b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,7 +25,7 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -37,7 +36,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -47,14 +46,14 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -62,7 +61,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -74,21 +73,21 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -97,14 +96,14 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -112,7 +111,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -122,14 +121,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -139,7 +138,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -147,7 +146,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -157,18 +156,18 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -177,7 +176,7 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -191,7 +190,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -199,7 +198,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -207,7 +206,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -215,7 +214,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -225,13 +224,13 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -241,7 +240,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -251,7 +250,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -261,7 +260,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -275,14 +274,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -292,7 +291,7 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py index f6f55e8dcfc9..12917503aa75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py @@ -16,6 +16,9 @@ from ._file_services_operations import FileServicesOperations from ._file_shares_operations import FileSharesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -27,3 +30,5 @@ 'FileServicesOperations', 'FileSharesOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py index b7f6d089d084..943dfb607adb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if skip_token is not None: - query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +214,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -218,16 +226,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -238,16 +245,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -255,23 +265,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -284,16 +292,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -301,23 +312,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -330,18 +339,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -350,25 +362,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -384,11 +394,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -397,23 +411,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -427,11 +439,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -440,22 +456,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -469,10 +483,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -480,22 +498,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -507,16 +523,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -524,24 +543,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -554,16 +571,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -571,49 +591,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -624,7 +640,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -635,24 +651,29 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param skip_token: Optional. Continuation token for the list operation. + :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -660,13 +681,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -674,13 +698,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -694,7 +721,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,7 +738,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -715,9 +746,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -741,13 +772,17 @@ def create( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -756,14 +791,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -781,7 +823,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -790,9 +832,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -815,13 +857,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -830,14 +876,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -851,7 +904,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -861,7 +914,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -881,11 +934,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -893,12 +951,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -912,11 +977,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -942,11 +1007,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -954,12 +1024,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -969,7 +1046,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -978,9 +1055,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1004,13 +1081,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1019,14 +1100,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1040,7 +1128,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1049,9 +1137,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1074,13 +1162,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1089,14 +1181,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,7 +1209,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1120,9 +1219,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1140,23 +1239,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1168,15 +1276,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1193,7 +1309,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1204,7 +1320,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1222,18 +1338,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1241,13 +1367,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1264,7 +1398,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1275,7 +1409,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, only way is to delete the @@ -1297,16 +1431,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1314,13 +1458,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1337,7 +1489,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1348,7 +1500,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1373,11 +1525,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1385,13 +1542,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1408,7 +1572,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1418,9 +1582,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1442,20 +1606,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1467,15 +1635,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1492,7 +1667,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1501,9 +1676,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1519,20 +1694,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1544,14 +1723,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1565,5 +1751,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py index 6ac5cfd910a4..27ac55976532 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-04-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py index f7fff262cc16..43cd349cf9e3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-04-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py index a17236994e26..333d516521e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if skip_token is not None: - query_parameters['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,10 +214,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -219,45 +229,41 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -268,7 +274,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,24 +284,29 @@ def list( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param skip_token: Optional. Continuation token for the list operation. + :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -303,13 +314,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -317,13 +331,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -337,7 +354,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -350,7 +371,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -358,9 +379,9 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -384,13 +405,17 @@ def create( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -399,14 +424,21 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -424,7 +456,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -433,9 +465,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -458,13 +490,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -473,14 +509,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -494,7 +537,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -504,7 +547,7 @@ def get( account_name: str, share_name: str, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -524,11 +567,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -536,12 +584,19 @@ def get( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -555,11 +610,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -585,11 +640,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -597,12 +657,19 @@ def delete( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -612,5 +679,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py index 50bb2ab1497f..c2162acbc90f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py index 2e8ae2a5d150..9578e48939a7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py index 1734fbd999e4..0ab17ac0b640 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py index eefd33b38609..ae6813ca3515 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[str] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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 = "2019-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -495,56 +511,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -557,26 +572,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -590,23 +616,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -614,14 +644,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -637,7 +674,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -645,9 +682,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -675,35 +712,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -712,13 +761,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -738,23 +786,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -764,7 +824,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -774,7 +834,7 @@ def get_properties( account_name: str, expand: Optional[str] = "geoReplicationStats", **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -788,31 +848,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - The default value is "geoReplicationStats". + Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -826,7 +898,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -834,9 +906,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -860,13 +932,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -874,14 +950,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -895,14 +978,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -913,29 +996,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -949,7 +1043,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -962,14 +1060,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -983,31 +1081,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1021,7 +1130,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1034,7 +1147,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1043,7 +1156,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1054,32 +1167,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1093,7 +1218,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1101,9 +1226,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1122,13 +1247,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1136,14 +1265,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1157,7 +1293,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1165,9 +1301,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1184,13 +1320,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1198,14 +1338,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1219,7 +1366,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1227,9 +1374,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1246,13 +1393,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1260,14 +1411,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1281,32 +1439,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1316,11 +1486,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1349,18 +1519,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1370,8 +1547,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1380,13 +1563,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1406,23 +1588,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1432,5 +1626,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py index 02358118a534..ff9c20826474 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_04_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py index cde92359b1cf..e0b46c23cefb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json index a943b8207251..a24a8684a71d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py index e0062f15a47d..91bc15a84877 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -70,8 +71,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -90,29 +94,65 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py index 25aa6326ab22..570411bf22fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py index 2c4ec8aa1042..4310862f67c8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,8 +73,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2019-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -92,24 +96,60 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py index 5d69f7e7c5aa..25083f1873e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py @@ -25,6 +25,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -45,3 +48,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py index 896fdc20b997..5d4c354b415d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -67,12 +65,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +161,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -173,13 +187,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -188,14 +206,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +238,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -222,9 +247,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -247,13 +272,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -262,14 +291,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +319,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -293,7 +329,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,11 +349,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -325,12 +366,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,11 +392,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -374,11 +422,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -386,12 +439,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -401,7 +461,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -410,9 +470,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -436,13 +496,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -451,14 +515,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +543,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -481,9 +552,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -506,13 +577,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -521,14 +596,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +624,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -552,9 +634,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -572,23 +654,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -600,15 +691,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -625,7 +724,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -636,7 +735,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -654,18 +753,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -673,13 +782,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,7 +813,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -707,7 +824,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -729,16 +846,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -746,13 +873,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -769,7 +904,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -780,7 +915,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -805,11 +940,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -817,13 +957,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -840,7 +987,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -850,9 +997,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -874,20 +1021,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -899,15 +1050,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -924,7 +1082,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -933,9 +1091,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -951,20 +1109,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -976,14 +1138,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,5 +1166,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py index 2ef9919a351e..f9217384d9c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py index 56ec56755b54..3e0316426304 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py index a5a7c64057ad..4d1ab9dfafe0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py index 07640499f9e2..44f02ad0f997 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py index c2f503a5c593..90ee26af22d8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = "deleted", **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,13 +64,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "deleted". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "deleted" or None. Default value is "deleted". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -80,11 +78,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +160,9 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -173,13 +186,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -188,14 +205,21 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +237,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -222,9 +246,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -247,13 +271,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -262,14 +290,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +318,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -294,7 +329,7 @@ async def get( share_name: str, expand: Optional[str] = "stats", **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -309,19 +344,24 @@ async def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -329,13 +369,20 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,11 +396,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -379,11 +426,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -391,12 +443,19 @@ async def delete( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -406,16 +465,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -439,13 +498,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -454,14 +517,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -471,5 +541,5 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py index 756f539d94f1..6274254e6b76 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py index 2affc86e8a61..97aa09894329 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -150,11 +163,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -162,12 +180,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,7 +207,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -191,9 +216,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -214,13 +239,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -229,14 +258,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,11 +287,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -279,11 +315,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -291,12 +332,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -307,5 +355,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py index 160908fe6d83..5034dfa03eed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py index 89be934bc5c6..430304bb2ba2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py index 14f2ca7677da..bb4a979afe70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py index 46d70814540f..7cc80ce86492 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py index a984ceeefab5..a38f3f21e73c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py index 3bc5b7c854cd..5db29af2be8e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py index b505bfb261fd..cffa49d6fedf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,25 +1056,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -916,14 +1085,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -941,7 +1117,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -949,9 +1125,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -977,35 +1153,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1014,13 +1202,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1040,23 +1227,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1066,5 +1265,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py index 4956d388ba97..4f5be6f6a2d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -113,7 +123,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -132,11 +142,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -144,12 +159,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +185,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -173,7 +195,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -192,11 +214,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -204,12 +231,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,11 +257,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -252,11 +286,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -264,12 +303,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -279,7 +325,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -288,7 +334,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -304,11 +350,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -316,10 +367,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -327,10 +381,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -344,7 +401,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,4 +418,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py index 4f7b036d5c7d..7ceb85c149ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py index 9ae1292bcb34..1e104d6d03cf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py index 8f8f46732b09..c297898e38e9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py @@ -177,7 +177,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'ActiveDirectoryProperties', @@ -347,3 +349,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py index fb1f9171b4c8..308c14a67347 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -21,22 +23,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2019_06_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -68,35 +70,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2019_06_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -276,8 +277,8 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2019_06_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -297,13 +298,13 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2019_06_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -345,18 +346,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -423,7 +423,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -435,7 +435,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -500,7 +500,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -534,7 +534,7 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - filters: "BlobInventoryPolicyFilter", + filters: "_models.BlobInventoryPolicyFilter", **kwargs ): """ @@ -631,7 +631,7 @@ def __init__( *, enabled: bool, name: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -659,7 +659,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar destination: Required. Container name where blob inventory files are stored. Must be pre-created. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2019_06_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -685,8 +685,8 @@ def __init__( *, enabled: bool, destination: str, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ @@ -695,7 +695,7 @@ def __init__( :keyword destination: Required. Container name where blob inventory files are stored. Must be pre-created. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2019_06_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -733,7 +733,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -793,8 +793,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -926,15 +926,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1030,7 +1030,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2019_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1090,7 +1090,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1156,7 +1156,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1203,7 +1203,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1454,7 +1454,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_06_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2019_06_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1478,17 +1478,17 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2019_06_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2019_06_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1518,11 +1518,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1557,18 +1557,18 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1659,7 +1659,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2019_06_01.models.KeyType """ @@ -1677,7 +1677,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -1686,7 +1686,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2019_06_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -1718,10 +1718,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -1789,8 +1789,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -1826,7 +1826,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -1943,8 +1943,8 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, **kwargs ): """ @@ -1985,10 +1985,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -1999,8 +1999,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2052,9 +2052,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2064,14 +2064,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier """ super(FileShare, self).__init__(**kwargs) @@ -2113,10 +2113,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2127,8 +2127,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2180,9 +2180,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2192,14 +2192,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier """ super(FileShareItem, self).__init__(**kwargs) @@ -2260,8 +2260,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2356,7 +2355,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2421,7 +2420,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2576,7 +2575,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2602,7 +2601,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -2611,7 +2610,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2633,8 +2632,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2664,7 +2663,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -2673,7 +2672,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2798,7 +2797,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -2894,18 +2893,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -2972,7 +2970,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -2984,7 +2982,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3268,7 +3266,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -3301,9 +3299,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -3346,9 +3344,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -3396,8 +3394,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -3441,7 +3439,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -3470,7 +3468,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2019_06_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyDefinition @@ -3493,8 +3491,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -3504,7 +3502,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2019_06_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyDefinition @@ -3537,7 +3535,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -3571,9 +3569,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3614,9 +3612,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3677,7 +3675,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -3723,15 +3721,15 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2019_06_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2019_06_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2019_06_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2019_06_01.models.DefaultAction """ @@ -3749,17 +3747,17 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2019_06_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: @@ -3767,7 +3765,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2019_06_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2019_06_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -3791,7 +3789,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -3851,7 +3849,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -3940,7 +3938,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -3985,9 +3983,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -4067,7 +4065,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -4125,7 +4123,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionProvisioningState """ @@ -4149,8 +4147,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4181,7 +4179,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -4260,7 +4258,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -4275,7 +4273,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4294,14 +4292,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4351,7 +4349,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -4430,7 +4428,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2019_06_01.models.ReasonCode """ @@ -4448,14 +4446,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2019_06_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -4468,7 +4466,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2019_06_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4487,14 +4485,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2019_06_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4517,17 +4515,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4588,10 +4586,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -4611,18 +4609,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -4689,7 +4686,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -4709,11 +4706,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_06_01.models.SkuTier """ @@ -4731,13 +4728,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName """ @@ -4787,17 +4784,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -4832,14 +4829,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -4931,13 +4928,13 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -4946,7 +4943,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2019_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -4958,7 +4955,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2019_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -4972,7 +4969,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -4990,7 +4987,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5006,8 +5003,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5083,14 +5080,14 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -5111,7 +5108,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5121,8 +5118,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5208,7 +5205,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -5233,7 +5230,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5245,7 +5242,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5255,8 +5252,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5294,30 +5291,30 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -5341,7 +5338,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5353,7 +5350,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5363,8 +5360,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5443,8 +5440,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.KeyPermission """ @@ -5632,8 +5629,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5643,7 +5640,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5654,7 +5651,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5664,8 +5661,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5695,20 +5692,20 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -5725,8 +5722,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5736,7 +5733,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5748,7 +5745,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5758,8 +5755,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5868,15 +5865,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2019_06_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2019_06_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -5895,25 +5892,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2019_06_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2019_06_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -6003,7 +6000,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -6120,7 +6117,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6174,7 +6171,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2019_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -6226,7 +6223,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -6280,7 +6277,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.State """ @@ -6300,7 +6297,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -6310,8 +6307,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2019_06_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py index c2f69ac92c11..0e02de120250 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,11 +25,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -40,7 +39,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -51,7 +50,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -61,7 +60,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -70,14 +69,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -85,7 +84,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -93,7 +92,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -101,14 +100,14 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -120,21 +119,21 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -143,20 +142,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -164,7 +163,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -173,7 +172,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -183,14 +182,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -200,7 +199,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -208,7 +207,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -218,22 +217,22 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -242,13 +241,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -262,7 +261,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -271,7 +270,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -279,7 +278,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -287,7 +286,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -295,7 +294,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -303,7 +302,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -313,7 +312,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -321,20 +320,20 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -344,7 +343,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -354,7 +353,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -364,7 +363,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -374,7 +373,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -388,14 +387,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -405,12 +404,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py index 5d69f7e7c5aa..25083f1873e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py @@ -25,6 +25,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -45,3 +48,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py index 440e92e8d075..27a604458202 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +214,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -218,16 +226,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -238,16 +245,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -255,23 +265,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -284,16 +292,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -301,23 +312,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -330,18 +339,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -350,25 +362,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -384,11 +394,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -397,23 +411,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -427,11 +439,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -440,22 +456,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -469,10 +483,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -480,22 +498,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -507,16 +523,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -524,24 +543,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -554,16 +571,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -571,49 +591,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -624,7 +640,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -636,23 +652,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -660,13 +682,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -674,13 +699,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -694,7 +722,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,7 +739,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -715,9 +747,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -741,13 +773,17 @@ def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -756,14 +792,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -781,7 +824,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -790,9 +833,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -815,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -830,14 +877,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -851,7 +905,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -861,7 +915,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -881,11 +935,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -893,12 +952,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -912,11 +978,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -942,11 +1008,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -954,12 +1025,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -969,7 +1047,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -978,9 +1056,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1004,13 +1082,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1019,14 +1101,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1040,7 +1129,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1049,9 +1138,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1074,13 +1163,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1089,14 +1182,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,7 +1210,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1120,9 +1220,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1140,23 +1240,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1168,15 +1277,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1193,7 +1310,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1204,7 +1321,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1222,18 +1339,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1241,13 +1368,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1264,7 +1399,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1275,7 +1410,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1297,16 +1432,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1314,13 +1459,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1337,7 +1490,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1348,7 +1501,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1373,11 +1526,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1385,13 +1543,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1408,7 +1573,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1418,9 +1583,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1442,20 +1607,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1467,15 +1636,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1492,7 +1668,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1501,9 +1677,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1519,20 +1695,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1544,14 +1724,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1565,5 +1752,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py index 58a6cc216347..d868be289228 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py index 55da7fe4a9af..ea195d3467d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py index 60c9a4868caf..fb22b1fcee7f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py index eeafad79cf00..626d3f93ef8f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py index 2493f1461b83..229b04dfc73d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[str] = "deleted", **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +177,14 @@ def build_get_request( expand: Optional[str] = "stats", **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -184,23 +192,21 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -212,10 +218,14 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -223,21 +233,19 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -248,16 +256,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -265,49 +276,45 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -318,7 +325,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = "deleted", **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -329,24 +336,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "deleted". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "deleted" or None. Default value is "deleted". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -354,13 +366,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -368,13 +383,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -388,7 +406,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -401,7 +423,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -409,9 +431,9 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -435,13 +457,17 @@ def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -450,14 +476,21 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -475,7 +508,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -484,9 +517,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -509,13 +542,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -524,14 +561,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -545,7 +589,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -556,7 +600,7 @@ def get( share_name: str, expand: Optional[str] = "stats", **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -571,19 +615,24 @@ def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -591,13 +640,20 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -611,11 +667,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -641,11 +697,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -653,12 +714,19 @@ def delete( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -668,16 +736,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -701,13 +769,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -716,14 +788,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -733,5 +812,5 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py index 2e15ad454755..a8efb7131602 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py index 09261be51d10..3e6aefff36ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -307,11 +327,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -319,12 +344,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,7 +371,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -348,9 +380,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -371,13 +403,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -386,14 +422,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,11 +451,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +479,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +496,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +519,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py index bfe27977e36c..085290392da8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py index 2c46eeaede6b..6a30f7b742c8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py index 08cb1c91fb33..fc9f1ab7fc73 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py index 06016f02ba58..d5c31166467a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,21 +583,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -553,12 +610,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -566,12 +626,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,7 +648,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,4 +665,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py index 96ad80a92a84..81a54a901675 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py index 7b8323daab5b..95e9d1e8701a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py index 470e1de69480..ca3a6ad053fd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -494,39 +510,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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 = "2019-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -539,56 +556,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -601,26 +617,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,23 +661,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -658,14 +689,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -681,7 +719,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -689,9 +727,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -719,35 +757,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -756,13 +806,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -782,23 +831,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -808,7 +869,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -818,7 +879,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -832,31 +893,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,7 +943,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -878,9 +951,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -904,13 +977,17 @@ def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -918,14 +995,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -939,14 +1023,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -957,29 +1041,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -993,7 +1088,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1006,14 +1105,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1027,31 +1126,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1065,7 +1175,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1192,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1087,7 +1201,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1098,32 +1212,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1137,7 +1263,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1145,9 +1271,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1166,13 +1292,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1180,14 +1310,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,7 +1338,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1209,9 +1346,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1228,13 +1365,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1242,14 +1383,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1263,7 +1411,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1271,9 +1419,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1290,13 +1438,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1304,14 +1456,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1325,32 +1484,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1360,11 +1531,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1393,18 +1564,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1414,8 +1592,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1424,25 +1608,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1450,14 +1637,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1475,7 +1669,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1483,9 +1677,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1510,35 +1704,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1547,13 +1753,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,23 +1778,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1599,5 +1816,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py index 5e3467eb25e5..40a41d36533a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,7 +308,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -297,7 +318,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,11 +337,16 @@ def update( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -328,12 +354,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,7 +380,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -357,7 +390,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -376,11 +409,16 @@ def get( :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -388,12 +426,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +452,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +481,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +498,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -463,7 +520,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -472,7 +529,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -487,11 +544,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -499,10 +561,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -510,10 +575,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -527,7 +595,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,4 +612,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py index 4f70389ac953..bd44848a61ce 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2019-06-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py index 1d5110749d9c..d05d3fed27dc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2019-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2019_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2019_06_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py index a996f0cfc927..e2e41142887d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-08-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-08-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json index c97e860595d1..10da1f8d0ba1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py index 351ca8b78cd5..b368bd63bfe9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -79,8 +80,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -99,30 +103,68 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py index aa973cb19691..2a4f903adb09 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-08-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-08-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py index 91dcd892f59d..2d630b1b84ed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -80,8 +81,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2020-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -100,25 +104,63 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py index 7f6fe519cbca..d308435f573e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -67,12 +65,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +161,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -173,13 +187,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -188,14 +206,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +238,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -222,9 +247,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -247,13 +272,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -262,14 +291,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +319,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -293,7 +329,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,11 +349,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -325,12 +366,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,11 +392,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -374,11 +422,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -386,12 +439,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -401,7 +461,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -410,9 +470,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -436,13 +496,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -451,14 +515,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +543,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -481,9 +552,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -506,13 +577,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -521,14 +596,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +624,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -552,9 +634,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -572,23 +654,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -600,15 +691,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -625,7 +724,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -636,7 +735,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -654,18 +753,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -673,13 +782,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,7 +813,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -707,7 +824,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -729,16 +846,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -746,13 +873,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -769,7 +904,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -780,7 +915,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -805,11 +940,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -817,13 +957,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -840,7 +987,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -850,9 +997,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -874,20 +1021,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -899,15 +1050,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -924,7 +1082,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -933,9 +1091,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -951,20 +1109,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -976,14 +1138,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,5 +1166,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py index acf37fbc6fc8..8b689eac9a47 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py index 7fa3666e2b39..99809800da5a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py index d3bee9dccaf7..6f9f9f9f1e8a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py index c92d04a48c6d..9dc5546fe9c8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py index 801821efe615..680f393846df 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py index a371d3596c62..826ee9bb9a06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,12 +64,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -79,11 +78,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -146,10 +160,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = "snapshots", **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -168,20 +182,25 @@ async def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :param expand: Optional, used to create a snapshot. The default value is "snapshots". + :param expand: Optional, used to create a snapshot. Known values are "snapshots" or None. + Default value is "snapshots". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -190,15 +209,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -216,7 +242,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -225,9 +251,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -250,13 +276,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -265,14 +295,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,7 +323,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -298,7 +335,7 @@ async def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,21 +350,27 @@ async def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -335,14 +378,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,11 +406,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -382,18 +432,23 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -401,13 +456,20 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -417,16 +479,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -450,13 +512,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -465,14 +531,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -482,5 +555,5 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py index c584859b67d3..254236fae99a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py index b6b5a201e7a9..e019fe59c7de 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -150,11 +163,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -162,12 +180,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,7 +207,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -191,9 +216,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -214,13 +239,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -229,14 +258,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,11 +287,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -279,11 +315,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -291,12 +332,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -307,5 +355,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py index 8eee687fb2f3..c0beaa620d09 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py index 9dcc1e653717..84c98a37d040 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py index 8a69188f3650..a45b623bf0a6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py index af7dd1724e9d..918f2765b9c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py index fed47babc9fa..03c0b7fd1a6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py index 32dd2f5aff5c..c527c7bf342c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py index 75f2220e087d..58ecdbb24035 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,25 +1056,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -916,14 +1085,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -941,7 +1117,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -949,9 +1125,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -977,35 +1153,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1014,13 +1202,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1040,23 +1227,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1066,5 +1265,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py index dd16f12af75c..8bd2073cb662 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -113,7 +123,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -132,11 +142,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -144,12 +159,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +185,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -173,7 +195,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -192,11 +214,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -204,12 +231,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,11 +257,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -252,11 +286,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -264,12 +303,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -279,7 +325,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -288,7 +334,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -304,11 +350,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -316,10 +367,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -327,10 +381,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -344,7 +401,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,4 +418,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py index 5991a1eabd32..9817b6eb6a49 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py index 35889f23efbb..b252cedde1a4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py index 7fca93457cc8..706491a695d5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py @@ -187,7 +187,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'ActiveDirectoryProperties', @@ -367,3 +369,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py index 71c7f845641f..652dca64d096 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -21,23 +23,23 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -69,36 +71,35 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -278,8 +279,8 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -299,13 +300,13 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -347,18 +348,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -425,7 +425,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -437,7 +437,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -502,7 +502,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -536,7 +536,7 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - filters: "BlobInventoryPolicyFilter", + filters: "_models.BlobInventoryPolicyFilter", **kwargs ): """ @@ -634,7 +634,7 @@ def __init__( *, enabled: bool, name: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -663,7 +663,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar destination: Required. Container name where blob inventory files are stored. Must be pre-created. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -689,8 +689,8 @@ def __init__( *, enabled: bool, destination: str, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ @@ -699,7 +699,7 @@ def __init__( :keyword destination: Required. Container name where blob inventory files are stored. Must be pre-created. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -737,7 +737,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -797,8 +797,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. @@ -932,15 +932,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1037,7 +1037,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1097,7 +1097,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1163,7 +1163,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1210,7 +1210,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1592,7 +1592,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1617,17 +1617,17 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1658,11 +1658,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1697,18 +1697,18 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1799,7 +1799,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyType """ @@ -1817,7 +1817,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -1826,7 +1826,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -1858,10 +1858,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -1929,8 +1929,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -1966,7 +1966,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2018,7 +2018,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocationTypes """ @@ -2031,13 +2031,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2118,9 +2118,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2164,11 +2164,11 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2179,8 +2179,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2237,9 +2237,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2249,15 +2249,15 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier """ super(FileShare, self).__init__(**kwargs) @@ -2300,11 +2300,11 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2315,8 +2315,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2373,9 +2373,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2385,15 +2385,15 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier """ super(FileShareItem, self).__init__(**kwargs) @@ -2455,8 +2455,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2551,7 +2550,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2617,7 +2616,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2772,7 +2771,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2798,7 +2797,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -2807,7 +2806,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2829,8 +2828,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2861,7 +2860,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -2870,7 +2869,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2996,7 +2995,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -3092,18 +3091,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3170,7 +3168,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -3182,7 +3180,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3466,7 +3464,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -3499,9 +3497,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -3544,9 +3542,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -3595,8 +3593,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -3640,7 +3638,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -3669,7 +3667,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyDefinition @@ -3692,8 +3690,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -3703,7 +3701,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: @@ -3737,7 +3735,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -3771,9 +3769,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3814,9 +3812,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3877,7 +3875,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -3948,8 +3946,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Bypass :ivar resource_access_rules: :vartype resource_access_rules: @@ -3960,7 +3958,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DefaultAction """ @@ -3979,18 +3977,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Bypass :keyword resource_access_rules: :paramtype resource_access_rules: @@ -4001,7 +3999,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4026,7 +4024,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4087,7 +4085,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -4177,7 +4175,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -4224,9 +4222,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -4307,7 +4305,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -4365,7 +4363,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionProvisioningState """ @@ -4389,8 +4387,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4421,7 +4419,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -4501,7 +4499,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -4516,7 +4514,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4535,14 +4533,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4571,7 +4569,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -4617,7 +4615,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -4728,7 +4726,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ReasonCode """ @@ -4746,14 +4744,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -4766,7 +4764,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4785,14 +4783,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4815,17 +4813,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4886,10 +4884,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -4909,18 +4907,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -4987,7 +4984,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5007,11 +5004,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuTier """ @@ -5029,13 +5026,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName """ @@ -5085,17 +5082,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5130,14 +5127,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -5168,7 +5165,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, **kwargs ): """ @@ -5254,7 +5251,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar identity: The identity of the resource. @@ -5262,7 +5259,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, @@ -5272,7 +5269,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5284,7 +5281,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. @@ -5299,7 +5296,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5318,7 +5315,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5334,8 +5331,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5413,15 +5410,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -5444,7 +5441,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5454,8 +5451,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5543,7 +5540,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -5572,7 +5569,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5584,7 +5581,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5594,8 +5591,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5635,31 +5632,31 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -5687,7 +5684,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5699,7 +5696,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5709,8 +5706,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5791,8 +5788,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyPermission """ @@ -5980,8 +5977,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5991,7 +5988,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6002,7 +5999,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6012,8 +6009,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -6044,20 +6041,20 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -6074,8 +6071,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6085,7 +6082,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6097,7 +6094,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6107,8 +6104,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -6218,15 +6215,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2020_08_01_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -6246,25 +6243,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2020_08_01_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). @@ -6355,7 +6352,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -6472,7 +6469,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -6527,7 +6524,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2020_08_01_preview.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -6579,7 +6576,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -6633,7 +6630,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.State """ @@ -6653,7 +6650,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -6663,8 +6660,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py index 49349134035e..40b46e1d43b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,11 +25,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -40,7 +39,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -51,7 +50,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -61,7 +60,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -70,14 +69,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -85,7 +84,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -93,7 +92,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -101,20 +100,20 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -126,21 +125,21 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -149,20 +148,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -170,7 +169,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -179,7 +178,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -189,14 +188,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -206,7 +205,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -214,7 +213,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -224,27 +223,27 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ListSharesExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" SNAPSHOTS = "snapshots" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -253,13 +252,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -273,7 +272,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -282,7 +281,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -290,7 +289,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -298,7 +297,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -306,7 +305,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -314,7 +313,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -324,7 +323,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -332,20 +331,20 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -355,7 +354,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -365,7 +364,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -375,7 +374,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -385,7 +384,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -399,14 +398,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -416,12 +415,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py index 80cf10817e99..4da4ab4869de 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +214,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -218,16 +226,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -238,16 +245,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -255,23 +265,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -284,16 +292,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -301,23 +312,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -330,18 +339,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -350,25 +362,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -384,11 +394,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -397,23 +411,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -427,11 +439,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -440,22 +456,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -469,10 +483,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -480,22 +498,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -507,16 +523,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -524,24 +543,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -554,16 +571,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -571,49 +591,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -624,7 +640,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -636,12 +652,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -649,11 +666,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -661,13 +683,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -675,13 +700,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -695,7 +723,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -708,7 +740,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -716,9 +748,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -742,13 +774,17 @@ def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -757,14 +793,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -782,7 +825,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -791,9 +834,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -816,13 +859,17 @@ def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -831,14 +878,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -852,7 +906,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -862,7 +916,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -882,11 +936,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -894,12 +953,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -913,11 +979,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -943,11 +1009,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -955,12 +1026,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -970,7 +1048,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -979,9 +1057,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1005,13 +1083,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1020,14 +1102,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1041,7 +1130,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1050,9 +1139,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1075,13 +1164,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1090,14 +1183,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1111,7 +1211,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1121,9 +1221,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1141,23 +1241,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1169,15 +1278,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1194,7 +1311,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1205,7 +1322,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1223,18 +1340,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1242,13 +1369,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,7 +1400,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1276,7 +1411,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1298,16 +1433,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1315,13 +1460,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1338,7 +1491,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1349,7 +1502,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1374,11 +1527,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1386,13 +1544,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1409,7 +1574,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1419,9 +1584,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1443,20 +1608,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1468,15 +1637,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1493,7 +1669,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1502,9 +1678,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1520,20 +1696,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1545,14 +1725,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1566,5 +1753,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py index 36235cc9969a..0e4efe2056a6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py index 55d1e075ff17..b2b54762cd27 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01-preview" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -188,11 +191,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -200,10 +208,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -211,10 +222,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -228,7 +242,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -241,16 +259,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -264,18 +282,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -283,14 +310,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,7 +339,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -313,7 +348,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -324,28 +359,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -359,5 +412,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py index 97fadf589f28..c6fd55924a57 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py index df4a728e0e6d..0bb3cd0629fe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py index e4796c17d541..2903fbb1f680 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01-preview" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py index 86adf7d1be22..442232f9d6e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[str] = "snapshots", **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -220,10 +226,14 @@ def build_delete_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -231,23 +241,21 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -258,16 +266,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -275,49 +286,45 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -328,7 +335,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -339,12 +346,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -352,11 +360,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -364,13 +377,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -378,13 +394,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -398,7 +417,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,7 +434,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -419,10 +442,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = "snapshots", **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -441,20 +464,25 @@ def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :param expand: Optional, used to create a snapshot. The default value is "snapshots". + :param expand: Optional, used to create a snapshot. Known values are "snapshots" or None. + Default value is "snapshots". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -463,15 +491,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -489,7 +524,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -498,9 +533,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -523,13 +558,17 @@ def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -538,14 +577,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -559,7 +605,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -571,7 +617,7 @@ def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -586,21 +632,27 @@ def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -608,14 +660,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -629,11 +688,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -655,18 +714,23 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -674,13 +738,20 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -690,16 +761,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -723,13 +794,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -738,14 +813,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -755,5 +837,5 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py index 87e44be371d5..acc5b6835ada 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py index 67188f61e351..120b84daeb94 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -307,11 +327,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -319,12 +344,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,7 +371,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -348,9 +380,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -371,13 +403,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -386,14 +422,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,11 +451,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +479,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +496,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +519,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py index 2cb78c470cf9..4ce62cdbb25f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py index 9479f31f363f..8001e195baaf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py index 865fc783c608..6002e71c78d0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py index 5aeb792bdb54..df8456c8f55e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,10 +583,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -542,11 +594,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -554,12 +611,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -567,12 +627,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -586,7 +649,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -599,4 +666,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py index 05e82e4ea813..ecb724300810 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01-preview" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py index 865105c90231..3f722df6ba7c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py index 029662b060ae..37c88bbf96ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -494,39 +510,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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 = "2020-08-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -539,56 +556,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -601,26 +617,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,23 +661,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -658,14 +689,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -681,7 +719,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -689,9 +727,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -720,35 +758,47 @@ def begin_create( ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -757,13 +807,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -783,23 +832,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -809,7 +870,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -819,7 +880,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -833,31 +894,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -871,7 +944,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -879,9 +952,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -905,13 +978,17 @@ def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -919,14 +996,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -940,14 +1024,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -958,29 +1042,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -994,7 +1089,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1007,14 +1106,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1028,31 +1127,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1066,7 +1176,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,7 +1193,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1088,7 +1202,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1099,32 +1213,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1138,7 +1264,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1146,9 +1272,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1167,13 +1293,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1181,14 +1311,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1202,7 +1339,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1210,9 +1347,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1229,13 +1366,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1243,14 +1384,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1264,7 +1412,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1272,9 +1420,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1291,13 +1439,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1305,14 +1457,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1326,32 +1485,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1361,11 +1532,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1394,18 +1565,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1415,8 +1593,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1425,25 +1609,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1451,14 +1638,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1476,7 +1670,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1484,9 +1678,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1512,35 +1706,47 @@ def begin_restore_blob_ranges( ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1549,13 +1755,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1575,23 +1780,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1601,5 +1818,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py index fc8fb783e0c5..8e1d4a009ca0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,7 +308,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -297,7 +318,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,11 +337,16 @@ def update( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -328,12 +354,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,7 +380,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -357,7 +390,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -376,11 +409,16 @@ def get( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -388,12 +426,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +452,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +481,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +498,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -463,7 +520,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -472,7 +529,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -488,11 +545,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -500,10 +562,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -511,10 +576,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -528,7 +596,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,4 +613,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py index ec36f4c089f6..bf33eb91921c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2020-08-01-preview" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py index ed8f319ecede..fa91cfeb9609 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2020-08-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2020_08_01_preview.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2020_08_01_preview.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -97,31 +98,42 @@ def list_by_location( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -135,7 +147,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -148,4 +164,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py index eb11f3bc54bd..0686be5dee06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json index 43e3fdf5b6fa..1131ce60c15e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py index cb38cc1147d4..a2a784f61f2d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,8 +73,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -92,30 +96,68 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py index f4d719417063..e1f9b184ecc8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-01-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py index c0bb8c66dbdc..414125d4b7a3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -75,8 +76,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -95,25 +99,63 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py index 6bb6f43e3dd2..9355bbce2770 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -67,12 +65,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +161,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -173,13 +187,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -188,14 +206,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +238,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -222,9 +247,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -247,13 +272,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -262,14 +291,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +319,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -293,7 +329,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,11 +349,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -325,12 +366,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,11 +392,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -374,11 +422,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -386,12 +439,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -401,7 +461,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -410,9 +470,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -436,13 +496,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -451,14 +515,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +543,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -481,9 +552,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -506,13 +577,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -521,14 +596,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +624,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -552,9 +634,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -572,23 +654,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -600,15 +691,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -625,7 +724,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -636,7 +735,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -654,18 +753,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -673,13 +782,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,7 +813,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -707,7 +824,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -729,16 +846,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -746,13 +873,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -769,7 +904,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -780,7 +915,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -805,11 +940,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -817,13 +957,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -840,7 +987,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -850,9 +997,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -874,20 +1021,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -899,15 +1050,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -924,7 +1082,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -933,9 +1091,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -951,20 +1109,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -976,14 +1138,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,5 +1166,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py index 238b0d6a1c9c..b20197d1060a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py index 98e8bfc3ee34..153be82df899 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py index ebe91e42f093..27225e2b022f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py index 626553538120..4057e0a146e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py index aea54c6e5e5e..5f1ba0bbbfee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py index 7bad8db4ed58..5f12ea03c6be 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,12 +64,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -79,11 +78,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -146,10 +160,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -168,20 +182,24 @@ async def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :param expand: Optional, used to create a snapshot. + :param expand: Optional, used to create a snapshot. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -190,15 +208,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -216,7 +241,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -225,9 +250,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -250,13 +275,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -265,14 +294,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,7 +322,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -298,7 +334,7 @@ async def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,21 +349,27 @@ async def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -335,14 +377,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,11 +405,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -382,18 +431,23 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -401,13 +455,20 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -417,16 +478,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -450,13 +511,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -465,14 +530,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -482,5 +554,5 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py index 8fe75b82a28d..75e79d302932 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py index fc657773b106..1acb9a27f80a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -150,11 +163,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -162,12 +180,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,7 +207,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -191,9 +216,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -214,13 +239,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -229,14 +258,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,11 +287,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -279,11 +315,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -291,12 +332,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -307,5 +355,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py index 6e451b49b564..087e97ae221e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py index fa430ce78543..d55a7f714237 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py index 4b8ac11aa009..0aa1ade8ea09 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py index 0df00dfdec06..ee6984a278d1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py index 67d87744f9ef..0f6f837411bc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py index 2adedceda8b2..68ff83d1a9f9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py index b84305e70585..2e3a8bd19b9e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_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")) # 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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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")) # 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._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,25 +1056,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -916,14 +1085,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -941,7 +1117,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -949,9 +1125,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -977,35 +1153,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_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")) # 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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1014,13 +1202,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1040,23 +1227,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1066,5 +1265,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py index 71f89b48abff..0df9183bf029 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -113,7 +123,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -132,11 +142,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -144,12 +159,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +185,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -173,7 +195,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -192,11 +214,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -204,12 +231,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,11 +257,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -252,11 +286,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -264,12 +303,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -279,7 +325,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -288,7 +334,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -304,11 +350,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -316,10 +367,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -327,10 +381,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -344,7 +401,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,4 +418,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py index ac6dab289036..658ee759a499 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py index a2cf547af05b..9826f267f3d2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py index aae11c1849bb..e50226e9eb1d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py @@ -191,7 +191,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'ActiveDirectoryProperties', @@ -375,3 +377,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py index f543a33f3837..fa18d76b9aba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -21,22 +23,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_01_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -68,35 +70,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_01_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -276,8 +277,8 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_01_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -297,13 +298,13 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_01_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -345,18 +346,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -423,7 +423,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -435,7 +435,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -500,7 +500,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -534,7 +534,7 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - filters: "BlobInventoryPolicyFilter", + filters: "_models.BlobInventoryPolicyFilter", **kwargs ): """ @@ -631,7 +631,7 @@ def __init__( *, enabled: bool, name: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -659,7 +659,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar destination: Required. Container name where blob inventory files are stored. Must be pre-created. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -685,8 +685,8 @@ def __init__( *, enabled: bool, destination: str, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ @@ -695,7 +695,7 @@ def __init__( :keyword destination: Required. Container name where blob inventory files are stored. Must be pre-created. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -733,7 +733,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -793,8 +793,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -926,15 +926,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1030,7 +1030,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_01_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1090,7 +1090,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1156,7 +1156,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1203,7 +1203,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1585,7 +1585,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_01_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_01_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1612,18 +1612,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_01_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_01_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1683,11 +1683,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1726,19 +1726,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1849,7 +1849,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_01_01.models.KeyType """ @@ -1867,7 +1867,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -1876,7 +1876,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_01_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -1908,10 +1908,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -1979,8 +1979,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2016,7 +2016,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2068,7 +2068,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocationTypes """ @@ -2081,13 +2081,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2168,9 +2168,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2214,10 +2214,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2228,8 +2228,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2286,9 +2286,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2298,14 +2298,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier """ super(FileShare, self).__init__(**kwargs) @@ -2348,10 +2348,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2362,8 +2362,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2420,9 +2420,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2432,14 +2432,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier """ super(FileShareItem, self).__init__(**kwargs) @@ -2501,8 +2501,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2549,7 +2548,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2575,12 +2574,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2615,7 +2614,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2680,7 +2679,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2835,7 +2834,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2861,7 +2860,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -2870,7 +2869,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2892,8 +2891,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2923,7 +2922,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -2932,7 +2931,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3057,7 +3056,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -3153,18 +3152,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3231,7 +3229,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -3243,7 +3241,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3527,7 +3525,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -3560,9 +3558,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -3605,9 +3603,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -3655,8 +3653,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -3700,7 +3698,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -3729,7 +3727,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyDefinition @@ -3752,8 +3750,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -3763,7 +3761,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyDefinition @@ -3796,7 +3794,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -3830,9 +3828,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3873,9 +3871,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3936,7 +3934,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4007,8 +4005,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_01_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_01_01.models.ResourceAccessRule] @@ -4017,7 +4015,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_01_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_01_01.models.DefaultAction """ @@ -4036,18 +4034,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_01_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4058,7 +4056,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_01_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_01_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4083,7 +4081,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4143,7 +4141,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -4232,7 +4230,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -4277,9 +4275,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -4359,7 +4357,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -4417,7 +4415,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionProvisioningState """ @@ -4441,8 +4439,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4473,7 +4471,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -4552,7 +4550,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -4567,7 +4565,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4586,14 +4584,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4622,7 +4620,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -4668,7 +4666,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -4779,7 +4777,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_01_01.models.ReasonCode """ @@ -4797,14 +4795,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_01_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -4817,7 +4815,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_01_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4836,14 +4834,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_01_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4866,17 +4864,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4937,10 +4935,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -4960,18 +4958,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5038,7 +5035,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5058,11 +5055,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_01_01.models.SkuTier """ @@ -5080,13 +5077,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName """ @@ -5136,17 +5133,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_01_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5181,14 +5178,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -5235,7 +5232,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -5341,7 +5338,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar identity: The identity of the resource. @@ -5349,7 +5346,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_01_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5358,7 +5355,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_01_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5370,7 +5367,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_01_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5384,7 +5381,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5402,7 +5399,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5418,8 +5415,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5499,15 +5496,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, **kwargs @@ -5531,7 +5528,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5541,8 +5538,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5632,7 +5629,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -5661,7 +5658,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5673,7 +5670,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5683,8 +5680,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5726,23 +5723,23 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, **kwargs @@ -5750,8 +5747,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -5779,7 +5776,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5791,7 +5788,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5801,8 +5798,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5885,8 +5882,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.KeyPermission """ @@ -6074,8 +6071,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6085,7 +6082,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6096,7 +6093,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6106,8 +6103,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6137,20 +6134,20 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -6167,8 +6164,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6178,7 +6175,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6190,7 +6187,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6200,8 +6197,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6310,15 +6307,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_01_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_01_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -6337,25 +6334,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_01_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_01_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -6445,7 +6442,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -6562,7 +6559,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6616,7 +6613,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_01_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -6668,7 +6665,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -6754,7 +6751,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.State """ @@ -6774,7 +6771,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -6784,8 +6781,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_01_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py index 38f7e753f257..18bb429d480d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,11 +25,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -40,7 +39,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -51,7 +50,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -61,7 +60,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -70,14 +69,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -85,7 +84,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -93,7 +92,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -101,20 +100,20 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -126,14 +125,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -142,14 +141,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -158,20 +157,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -179,7 +178,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -188,7 +187,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -198,14 +197,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -215,7 +214,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -223,7 +222,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -233,27 +232,27 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ListSharesExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" SNAPSHOTS = "snapshots" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -262,13 +261,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -282,7 +281,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -291,7 +290,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -299,7 +298,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -307,7 +306,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -315,11 +314,11 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class PutSharesExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PutSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): SNAPSHOTS = "snapshots" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -327,7 +326,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -337,7 +336,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -345,20 +344,20 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -368,7 +367,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -378,7 +377,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -388,7 +387,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -398,7 +397,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -412,14 +411,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -429,12 +428,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py index baed2e336681..8546383ef85c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +214,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -218,16 +226,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -238,16 +245,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -255,23 +265,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -284,16 +292,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -301,23 +312,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -330,18 +339,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -350,25 +362,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -384,11 +394,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -397,23 +411,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -427,11 +439,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -440,22 +456,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -469,10 +483,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -480,22 +498,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -507,16 +523,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -524,24 +543,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -554,16 +571,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -571,49 +591,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -624,7 +640,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -636,23 +652,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -660,13 +682,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -674,13 +699,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -694,7 +722,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,7 +739,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -715,9 +747,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -741,13 +773,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -756,14 +792,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -781,7 +824,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -790,9 +833,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -815,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -830,14 +877,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -851,7 +905,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -861,7 +915,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -881,11 +935,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -893,12 +952,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -912,11 +978,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -942,11 +1008,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -954,12 +1025,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -969,7 +1047,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -978,9 +1056,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1004,13 +1082,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1019,14 +1101,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1040,7 +1129,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1049,9 +1138,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1074,13 +1163,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1089,14 +1182,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,7 +1210,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1120,9 +1220,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1140,23 +1240,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1168,15 +1277,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1193,7 +1310,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1204,7 +1321,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1222,18 +1339,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1241,13 +1368,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1264,7 +1399,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1275,7 +1410,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1297,16 +1432,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1314,13 +1459,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1337,7 +1490,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1348,7 +1501,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1373,11 +1526,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1385,13 +1543,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1408,7 +1573,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1418,9 +1583,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1442,20 +1607,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1467,15 +1636,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1492,7 +1668,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1501,9 +1677,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1519,20 +1695,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1544,14 +1724,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1565,5 +1752,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py index af6d91a90056..7629c296a612 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py index 7a8fd808b1fe..151a7b578c04 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py index 248413c7f014..b93535f0bfaa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py index b6e6688d11a5..750ac842cb0d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py index 3d9d06fe5edf..e7147163b52f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py index 62cba64ea9b4..c56e9fedbed2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -220,10 +226,14 @@ def build_delete_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -231,23 +241,21 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -258,16 +266,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -275,49 +286,45 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -328,7 +335,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -339,23 +346,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -363,13 +376,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -377,13 +393,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +416,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,7 +433,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -418,10 +441,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -440,20 +463,24 @@ def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :param expand: Optional, used to create a snapshot. + :param expand: Optional, used to create a snapshot. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -462,15 +489,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -488,7 +522,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -497,9 +531,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -522,13 +556,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -537,14 +575,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -558,7 +603,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -570,7 +615,7 @@ def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -585,21 +630,27 @@ def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -607,14 +658,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -628,11 +686,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -654,18 +712,23 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -673,13 +736,20 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -689,16 +759,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -722,13 +792,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -737,14 +811,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,5 +835,5 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py index 81af5a7e3d31..008ce8c80c71 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py index e2dd287e7239..c9e110b5a3ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -307,11 +327,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -319,12 +344,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,7 +371,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -348,9 +380,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -371,13 +403,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -386,14 +422,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,11 +451,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +479,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +496,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +519,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py index 34e67d1dbce8..c5f41824146a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py index 0486de9f0726..fa12779a547a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py index 7a77da0a4acf..81443bac130a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py index 5ab075bc68e3..18c906589a10 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,21 +583,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -553,12 +610,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -566,12 +626,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,7 +648,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,4 +665,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py index 7c4b937c73bb..d28d1b045ca7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py index ce8849bad2f6..664da336b8d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py index 3efe58db5a4a..11f13a3456e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -494,39 +510,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -539,56 +556,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -601,26 +617,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,23 +661,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -658,14 +689,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -681,7 +719,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -689,9 +727,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -719,35 +757,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_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")) # 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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -756,13 +806,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -782,23 +831,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -808,7 +869,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -818,7 +879,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -832,31 +893,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,7 +943,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -878,9 +951,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -904,13 +977,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -918,14 +995,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -939,14 +1023,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -957,29 +1041,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -993,7 +1088,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1006,14 +1105,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1027,31 +1126,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1065,7 +1175,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1192,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1087,7 +1201,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1098,32 +1212,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1137,7 +1263,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1145,9 +1271,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1166,13 +1292,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1180,14 +1310,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,7 +1338,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1209,9 +1346,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1228,13 +1365,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1242,14 +1383,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1263,7 +1411,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1271,9 +1419,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1290,13 +1438,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1304,14 +1456,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1325,32 +1484,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1360,11 +1531,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1393,18 +1564,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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")) # 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._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1414,8 +1592,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1424,25 +1608,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1450,14 +1637,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1475,7 +1669,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1483,9 +1677,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1510,35 +1704,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_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")) # 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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1547,13 +1753,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,23 +1778,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1599,5 +1816,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py index 2052e164ab9e..57d12e08be7b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,7 +308,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -297,7 +318,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,11 +337,16 @@ def update( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -328,12 +354,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,7 +380,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -357,7 +390,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -376,11 +409,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -388,12 +426,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +452,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +481,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +498,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -463,7 +520,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -472,7 +529,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -487,11 +544,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -499,10 +561,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -510,10 +575,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -527,7 +595,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,4 +612,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py index 8d957806f594..00744a5403e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-01-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py index c1ff00f7a536..20aef2cc985b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-01-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_01_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_01_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py index 4639f88f360f..33fa3a464384 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-02-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json index aa6f7acf22e6..fd77f718b432 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py index ac503a61e234..54c29d928402 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,8 +73,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -92,30 +96,68 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py index 16da1f3188df..c4ec19bcf03f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-02-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-02-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py index fa820f3c5bd8..3ebd13841c38 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -75,8 +76,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -95,25 +99,63 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py index 21bc3f7f4d79..7d1829d5c90d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -67,12 +65,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -147,9 +161,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -173,13 +187,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -188,14 +206,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -213,7 +238,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -222,9 +247,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -247,13 +272,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -262,14 +291,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -283,7 +319,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -293,7 +329,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,11 +349,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -325,12 +366,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -344,11 +392,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -374,11 +422,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -386,12 +439,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -401,7 +461,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -410,9 +470,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -436,13 +496,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -451,14 +515,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,7 +543,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -481,9 +552,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -506,13 +577,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -521,14 +596,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -542,7 +624,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -552,9 +634,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -572,23 +654,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -600,15 +691,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -625,7 +724,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -636,7 +735,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -654,18 +753,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -673,13 +782,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,7 +813,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -707,7 +824,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -729,16 +846,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -746,13 +873,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -769,7 +904,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -780,7 +915,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -805,11 +940,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -817,13 +957,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -840,7 +987,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -850,9 +997,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -874,20 +1021,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -899,15 +1050,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -924,7 +1082,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -933,9 +1091,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -951,20 +1109,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -976,14 +1138,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -997,5 +1166,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py index 570b62d2e149..e71707a26c3f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py index 492456411dee..45724be01a06 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py index 28d0cbf8f654..4cb974e06749 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py index 051c1d6e475a..14dd0da30aef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py index 50d1e18742a9..bdcf3b98ab74 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py index 4547bd16f533..c9b6c343b7c2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,12 +64,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -79,11 +78,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -91,13 +95,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -105,13 +112,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -125,7 +135,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -138,7 +152,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -146,10 +160,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -168,20 +182,24 @@ async def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :param expand: Optional, used to create a snapshot. + :param expand: Optional, used to create a snapshot. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -190,15 +208,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -216,7 +241,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -225,9 +250,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -250,13 +275,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -265,14 +294,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,7 +322,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -298,7 +334,7 @@ async def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -313,21 +349,27 @@ async def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -335,14 +377,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,11 +405,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -382,18 +431,23 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -401,13 +455,20 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -417,16 +478,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -450,13 +511,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -465,14 +530,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -482,5 +554,5 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py index e4f78432c2a8..6d1edb2fa4ad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py index 4697cb820a46..afa29741c911 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -150,11 +163,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -162,12 +180,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,7 +207,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -191,9 +216,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -214,13 +239,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -229,14 +258,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,11 +287,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -279,11 +315,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -291,12 +332,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -307,5 +355,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py index c4bb5dfc8069..f8ebf1952a2e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py index c49d1f31e791..8f5031dc10e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py index 69ffbf500d31..1a8e80feae68 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py index d846b7c3ea8a..acff7b617a65 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py index 41d3980c43ac..3b2d5f4b4e60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py index 8f672833aa43..648b1bd6c765 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py index 2e9cabb1509d..1cf6dc6bef43 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,25 +1056,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -916,14 +1085,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -941,7 +1117,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -949,9 +1125,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -977,35 +1153,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1014,13 +1202,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1040,23 +1227,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1066,5 +1265,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py index f5489bfecfd2..f72f353d9069 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -113,7 +123,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -132,11 +142,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -144,12 +159,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +185,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -173,7 +195,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -192,11 +214,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -204,12 +231,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,11 +257,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -252,11 +286,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -264,12 +303,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -279,7 +325,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -288,7 +334,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -304,11 +350,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -316,10 +367,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -327,10 +381,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -344,7 +401,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,4 +418,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py index 82a1b18b0dbd..162cbd802b30 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py index 6d24b462b3c3..260e91f4432d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py index 684042857a02..82c172aa1eb5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py @@ -195,7 +195,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccountSasParameters', 'ActiveDirectoryProperties', @@ -383,3 +385,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py index 898b0261417a..ab0b5c75d766 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccountSasParameters(msrest.serialization.Model): @@ -21,22 +23,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_02_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -68,35 +70,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_02_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -276,8 +277,8 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_02_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -297,13 +298,13 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_02_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -345,18 +346,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -423,7 +423,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -435,7 +435,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -500,7 +500,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -534,7 +534,7 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - filters: "BlobInventoryPolicyFilter", + filters: "_models.BlobInventoryPolicyFilter", **kwargs ): """ @@ -631,7 +631,7 @@ def __init__( *, enabled: bool, name: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -659,7 +659,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar destination: Required. Container name where blob inventory files are stored. Must be pre-created. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -685,8 +685,8 @@ def __init__( *, enabled: bool, destination: str, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ @@ -695,7 +695,7 @@ def __init__( :keyword destination: Required. Container name where blob inventory files are stored. Must be pre-created. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -733,7 +733,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -793,8 +793,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -926,15 +926,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1030,7 +1030,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_02_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1090,7 +1090,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1156,7 +1156,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1203,7 +1203,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1585,7 +1585,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_02_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_02_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1612,18 +1612,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_02_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_02_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1683,11 +1683,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1726,19 +1726,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1849,7 +1849,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_02_01.models.KeyType """ @@ -1867,7 +1867,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -1876,7 +1876,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_02_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -1908,10 +1908,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -1979,8 +1979,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2016,7 +2016,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2068,7 +2068,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocationTypes """ @@ -2081,13 +2081,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2168,9 +2168,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2214,10 +2214,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2228,8 +2228,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2286,9 +2286,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2298,14 +2298,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier """ super(FileShare, self).__init__(**kwargs) @@ -2348,10 +2348,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2362,8 +2362,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2420,9 +2420,9 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, **kwargs ): """ @@ -2432,14 +2432,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier """ super(FileShareItem, self).__init__(**kwargs) @@ -2501,8 +2501,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2549,7 +2548,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2575,12 +2574,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2615,7 +2614,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2680,7 +2679,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2898,7 +2897,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2924,7 +2923,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -2933,7 +2932,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2955,8 +2954,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2986,7 +2985,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -2995,7 +2994,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3120,7 +3119,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -3216,18 +3215,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3294,7 +3292,7 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, **kwargs ): @@ -3306,7 +3304,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3590,7 +3588,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -3623,9 +3621,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -3668,9 +3666,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -3718,8 +3716,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -3763,7 +3761,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -3792,7 +3790,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyDefinition @@ -3815,8 +3813,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -3826,7 +3824,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyDefinition @@ -3859,7 +3857,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -3893,9 +3891,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3936,9 +3934,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -3999,7 +3997,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4070,8 +4068,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_02_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_02_01.models.ResourceAccessRule] @@ -4080,7 +4078,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_02_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_02_01.models.DefaultAction """ @@ -4099,18 +4097,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_02_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4121,7 +4119,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_02_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_02_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4146,7 +4144,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4206,7 +4204,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -4295,7 +4293,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -4340,9 +4338,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -4422,7 +4420,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -4480,7 +4478,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionProvisioningState """ @@ -4504,8 +4502,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4536,7 +4534,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -4615,7 +4613,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -4630,7 +4628,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4649,14 +4647,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4685,7 +4683,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -4731,7 +4729,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -4842,7 +4840,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_02_01.models.ReasonCode """ @@ -4860,14 +4858,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_02_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -4880,7 +4878,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_02_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4899,14 +4897,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_02_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4928,8 +4926,8 @@ class SasPolicy(msrest.serialization.Model): :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Possible values - include: "Log". Default value: "Log". + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :vartype expiration_action: str or ~azure.mgmt.storage.v2021_02_01.models.ExpirationAction """ @@ -4947,14 +4945,14 @@ def __init__( self, *, sas_expiration_period: str, - expiration_action: Union[str, "ExpirationAction"] = "Log", + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Possible - values include: "Log". Default value: "Log". + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_02_01.models.ExpirationAction """ super(SasPolicy, self).__init__(**kwargs) @@ -4970,17 +4968,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5041,10 +5039,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -5064,18 +5062,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5142,7 +5139,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5162,11 +5159,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_02_01.models.SkuTier """ @@ -5184,13 +5181,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName """ @@ -5240,17 +5237,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_02_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5285,14 +5282,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -5339,7 +5336,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -5445,7 +5442,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar identity: The identity of the resource. @@ -5453,7 +5450,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_02_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5462,7 +5459,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_02_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5474,7 +5471,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_02_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5494,7 +5491,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5512,7 +5509,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5528,8 +5525,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5615,15 +5612,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, **kwargs @@ -5647,7 +5644,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5657,8 +5654,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5751,7 +5748,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -5784,7 +5781,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5796,7 +5793,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5806,8 +5803,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5851,25 +5848,25 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, **kwargs @@ -5877,8 +5874,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -5910,7 +5907,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5922,7 +5919,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5932,8 +5929,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6018,8 +6015,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime @@ -6212,8 +6209,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6227,7 +6224,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_02_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6238,7 +6235,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6248,8 +6245,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6281,22 +6278,22 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, **kwargs ): @@ -6313,8 +6310,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6328,7 +6325,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_02_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6340,7 +6337,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6350,8 +6347,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6462,15 +6459,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_02_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_02_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -6489,25 +6486,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_02_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_02_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -6597,7 +6594,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -6714,7 +6711,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6768,7 +6765,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_02_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -6820,7 +6817,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -6906,7 +6903,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.State """ @@ -6926,7 +6923,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -6936,8 +6933,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "provisioning", "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", + "deprovisioning", "succeeded", "failed", "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_02_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py index 2c4c8c6bcf53..da1c97b2f356 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,11 +25,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -40,7 +39,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -51,7 +50,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -61,7 +60,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -70,14 +69,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -85,7 +84,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -93,7 +92,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -101,26 +100,26 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExpirationAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SAS expiration action. Can only be Log. """ LOG = "Log" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -132,14 +131,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -148,14 +147,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -164,20 +163,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -185,7 +184,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -194,7 +193,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -204,14 +203,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -221,7 +220,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -229,7 +228,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -239,27 +238,27 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ListSharesExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" SNAPSHOTS = "snapshots" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -268,13 +267,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -288,7 +287,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -297,7 +296,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -305,7 +304,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -313,7 +312,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -321,11 +320,11 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class PutSharesExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PutSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): SNAPSHOTS = "snapshots" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -333,7 +332,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -343,7 +342,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -351,20 +350,20 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -374,7 +373,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -384,7 +383,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -394,7 +393,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -404,7 +403,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -418,14 +417,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -435,12 +434,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py index 36a7bdbf7015..589724cade39 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,16 +80,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -95,23 +100,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -124,16 +127,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -141,23 +147,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -171,10 +175,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -182,21 +190,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -208,9 +214,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -218,16 +226,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -238,16 +245,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -255,23 +265,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -284,16 +292,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -301,23 +312,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -330,18 +339,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -350,25 +362,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -384,11 +394,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -397,23 +411,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -427,11 +439,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -440,22 +456,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -469,10 +483,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -480,22 +498,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -507,16 +523,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -524,24 +543,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -554,16 +571,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -571,49 +591,45 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -624,7 +640,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -636,23 +652,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -660,13 +682,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -674,13 +699,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -694,7 +722,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,7 +739,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -715,9 +747,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -741,13 +773,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -756,14 +792,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -781,7 +824,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -790,9 +833,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -815,13 +858,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -830,14 +877,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -851,7 +905,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -861,7 +915,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -881,11 +935,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -893,12 +952,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -912,11 +978,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -942,11 +1008,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -954,12 +1025,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -969,7 +1047,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -978,9 +1056,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1004,13 +1082,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1019,14 +1101,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1040,7 +1129,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1049,9 +1138,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1074,13 +1163,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1089,14 +1182,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1110,7 +1210,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1120,9 +1220,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1140,23 +1240,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1168,15 +1277,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1193,7 +1310,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1204,7 +1321,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1222,18 +1339,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1241,13 +1368,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1264,7 +1399,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1275,7 +1410,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1297,16 +1432,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1314,13 +1459,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1337,7 +1490,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1348,7 +1501,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1373,11 +1526,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1385,13 +1543,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1408,7 +1573,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1418,9 +1583,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1442,20 +1607,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1467,15 +1636,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1492,7 +1668,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1501,9 +1677,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1519,20 +1695,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1544,14 +1724,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1565,5 +1752,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py index c76a677f9dd4..7e9d4bff0cab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py index 7258c47141f5..c0f0e9c994d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py index 024fc693070e..b6e66a18bf53 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py index 80fc9f9a9203..e4ab7b5b08f9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py index 50884aa0129c..25b38a6afafb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py index e17c0cebafed..783c42ac8c31 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -220,10 +226,14 @@ def build_delete_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -231,23 +241,21 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -258,16 +266,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -275,49 +286,45 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -328,7 +335,7 @@ def list( filter: Optional[str] = None, expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -339,23 +346,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. + :param expand: Optional, used to expand the properties within share's properties. Default value + is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -363,13 +376,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -377,13 +393,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -397,7 +416,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,7 +433,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -418,10 +441,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -440,20 +463,24 @@ def create( :type share_name: str :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :param expand: Optional, used to create a snapshot. + :param expand: Optional, used to create a snapshot. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -462,15 +489,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -488,7 +522,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -497,9 +531,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -522,13 +556,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -537,14 +575,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -558,7 +603,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -570,7 +615,7 @@ def get( expand: Optional[str] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -585,21 +630,27 @@ def get( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param expand: Optional, used to expand the properties within share's properties. The default - value is "stats". + :param expand: Optional, used to expand the properties within share's properties. Known values + are "stats" or None. Default value is "stats". :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -607,14 +658,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -628,11 +686,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -654,18 +712,23 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: 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 """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -673,13 +736,20 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -689,16 +759,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -722,13 +792,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -737,14 +811,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,5 +835,5 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py index 26c3ae219f70..fd668860dc8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py index 716cf2ec567d..80eec726662a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -307,11 +327,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -319,12 +344,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -339,7 +371,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -348,9 +380,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -371,13 +403,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -386,14 +422,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -408,11 +451,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +479,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +496,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -464,5 +519,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py index 0c5caf21402b..b90d35706aab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py index 08ad3424c854..3a8475955e5d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py index 24c367dcc20a..def4e04b795d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py index 2cd75c653626..2f0b1f7be401 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,21 +583,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -553,12 +610,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -566,12 +626,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,7 +648,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,4 +665,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py index a1b09c9461d6..f8995361ae52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py index d53fc785928c..b15dba59e858 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py index e7ea8b44b2d3..27bcf46391f7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -494,39 +510,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -539,56 +556,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -601,26 +617,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,23 +661,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -658,14 +689,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -681,7 +719,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -689,9 +727,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -719,35 +757,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -756,13 +806,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -782,23 +831,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -808,7 +869,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -818,7 +879,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -832,31 +893,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,7 +943,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -878,9 +951,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -904,13 +977,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -918,14 +995,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -939,14 +1023,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -957,29 +1041,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -993,7 +1088,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1006,14 +1105,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1027,31 +1126,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1065,7 +1175,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1192,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1087,7 +1201,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1098,32 +1212,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1137,7 +1263,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1145,9 +1271,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1166,13 +1292,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1180,14 +1310,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,7 +1338,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1209,9 +1346,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1228,13 +1365,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1242,14 +1383,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1263,7 +1411,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1271,9 +1419,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1290,13 +1438,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1304,14 +1456,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1325,32 +1484,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1360,11 +1531,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1393,18 +1564,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1414,8 +1592,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1424,25 +1608,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1450,14 +1637,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1475,7 +1669,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1483,9 +1677,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1510,35 +1704,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1547,13 +1753,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,23 +1778,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1599,5 +1816,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py index 9b6d2b8c9cf2..6a9c424dcc60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,7 +308,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -297,7 +318,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,11 +337,16 @@ def update( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -328,12 +354,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,7 +380,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -357,7 +390,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -376,11 +409,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -388,12 +426,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +452,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +481,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +498,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -463,7 +520,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -472,7 +529,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -487,11 +544,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -499,10 +561,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -510,10 +575,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -527,7 +595,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,4 +612,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py index cb265d449b3e..92ff96e5ca85 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-02-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py index 99a3c9fc116c..43a7bbbc1005 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_02_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_02_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py index 84908f76532b..f79f8e02325e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json index b21b95219e92..3a4347381ea3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py index 8cacd6b7c870..54d204bbbb21 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,8 +73,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -92,30 +96,68 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py index 9ba3f2dc71c9..35f75c7989c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-04-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-04-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py index 19c81e0f0a0b..c70345d3dcb4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -75,8 +76,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-04-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -95,25 +99,63 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py index a093d01675bd..d74cda44e72e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -57,7 +55,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -69,12 +67,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -82,11 +81,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +98,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +115,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -149,9 +163,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -175,13 +189,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -190,14 +208,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -215,7 +240,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -224,9 +249,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -249,13 +274,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -264,14 +293,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,7 +321,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -295,7 +331,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -315,11 +351,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -327,12 +368,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,11 +394,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -376,11 +424,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -388,12 +441,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -403,7 +463,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -412,9 +472,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -438,13 +498,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -453,14 +517,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,7 +545,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -483,9 +554,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -508,13 +579,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -523,14 +598,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +626,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -554,9 +636,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -574,23 +656,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -602,15 +693,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -627,7 +726,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -638,7 +737,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -656,18 +755,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -675,13 +784,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,7 +815,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -709,7 +826,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -731,16 +848,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -748,13 +875,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,7 +906,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -782,7 +917,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -807,11 +942,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -819,13 +959,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -842,7 +989,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -852,9 +999,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -876,20 +1023,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -901,15 +1052,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,7 +1084,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -935,9 +1093,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -953,20 +1111,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -978,14 +1140,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -999,21 +1168,26 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - async def _object_level_worm_initial( + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1021,12 +1195,19 @@ async def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1036,11 +1217,11 @@ async def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( + async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1076,19 +1257,26 @@ async def begin_object_level_worm( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._object_level_worm_initial( + raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1098,8 +1286,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1108,7 +1302,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py index 1ce152b88419..7f99163cbee2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py index 0ab3345263d0..e3112018c2c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py index b9cfeddc1147..7a936d8f713f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py index e9981b389526..f5c72d7c7112 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py index 1d8989a361cc..26e8a5f6eeef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py index f84326c85c44..8a405d076630 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,13 +64,14 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,7 +154,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -148,10 +162,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -171,20 +185,24 @@ async def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -193,15 +211,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -220,7 +245,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -229,9 +254,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -254,13 +279,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -269,14 +298,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,7 +327,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -303,7 +339,7 @@ async def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -319,20 +355,26 @@ async def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -340,14 +382,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,11 +411,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -389,7 +438,7 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -403,11 +452,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -415,14 +469,21 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -433,16 +494,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -466,13 +527,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -481,14 +546,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -499,7 +571,7 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace_async @@ -509,9 +581,9 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -527,22 +599,27 @@ async def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -554,15 +631,22 @@ async def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -580,5 +664,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py index 36179b99e6c3..6b92981369c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py index 1a40b9bcd7a6..15adfb5f9e5a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -152,11 +165,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -164,12 +182,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +209,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -193,9 +218,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -218,13 +243,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -233,14 +262,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,11 +291,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -285,11 +321,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -297,12 +338,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -313,5 +361,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py index fb7fdb3e0719..bef21540dd1b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py index 52eb4c9342f1..478f6f5d4c50 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py index 3100d697ce88..cb9a5b1ab8a2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py index f5d13f2a3bbe..5915e46055a0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,7 +122,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -122,9 +131,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -146,13 +155,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -161,14 +174,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,7 +203,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -193,7 +213,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -213,11 +233,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -225,12 +250,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,11 +277,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -275,11 +307,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -287,12 +324,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -303,7 +347,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -314,7 +358,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -325,10 +369,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -336,11 +380,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -348,12 +397,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -361,12 +413,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +435,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,4 +453,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py index b9d96b4025ef..88c3bc2db99f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py index 0724b60000da..02e35eed4fab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py index 9934023f188a..fabbc3e0fe65 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,33 +27,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,25 +1056,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -916,14 +1085,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -941,7 +1117,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -949,9 +1125,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -977,35 +1153,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1014,13 +1202,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1040,23 +1227,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1066,5 +1265,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py index 8424f123fb22..8c76184dd0f3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -114,7 +124,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,11 +143,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -145,12 +160,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -165,7 +187,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -175,7 +197,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -194,11 +216,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -206,12 +233,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -226,11 +260,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -255,11 +289,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -267,12 +306,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -283,7 +329,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -292,7 +338,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -308,11 +354,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -320,10 +371,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,10 +385,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -348,7 +405,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,4 +423,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py index 46ce22c14dc0..df12e59d7453 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py index 161eeda8c0fb..754930cf7cef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py index 500bda621a86..8cfef998e7d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py @@ -206,7 +206,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccessPolicy', 'AccountSasParameters', @@ -405,3 +407,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py index c1cb0392e6bf..25d4168458bb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessPolicy(msrest.serialization.Model): @@ -60,22 +62,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_04_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -107,35 +109,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_04_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -315,15 +316,15 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_04_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. :vartype active_directory_properties: ~azure.mgmt.storage.v2021_04_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor", "StorageFileDataSmbShareOwner". :vartype default_share_permission: str or @@ -343,21 +344,21 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, - default_share_permission: Optional[Union[str, "DefaultSharePermission"]] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_04_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_04_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor", "StorageFileDataSmbShareOwner". :paramtype default_share_permission: str or @@ -399,18 +400,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -483,9 +483,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, **kwargs ): """ @@ -496,7 +496,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -567,7 +567,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -589,14 +589,13 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyFilter :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_04_01.models.Format :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Possible values include: "Daily", "Weekly". + formation. Known values are: "Daily", "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_04_01.models.Schedule :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_04_01.models.ObjectType :ivar schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -629,25 +628,24 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - format: Union[str, "Format"], - schedule: Union[str, "Schedule"], - object_type: Union[str, "ObjectType"], + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], schema_fields: List[str], - filters: Optional["BlobInventoryPolicyFilter"] = None, + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, **kwargs ): """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyFilter :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_04_01.models.Format :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Possible values include: "Daily", "Weekly". + inventory formation. Known values are: "Daily", "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_04_01.models.Schedule :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_04_01.models.ObjectType :keyword schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -764,7 +762,7 @@ def __init__( enabled: bool, name: str, destination: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -793,7 +791,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar enabled: Required. Policy is enabled if set to true. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -816,14 +814,14 @@ def __init__( self, *, enabled: bool, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ :keyword enabled: Required. Policy is enabled if set to true. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -860,7 +858,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -920,8 +918,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1053,15 +1051,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1157,7 +1155,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_04_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1202,7 +1200,7 @@ class CloudErrorAutoGenerated(msrest.serialization.Model): def __init__( self, *, - error: Optional["CloudErrorBodyAutoGenerated"] = None, + error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, **kwargs ): """ @@ -1242,7 +1240,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1294,7 +1292,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBodyAutoGenerated"]] = None, + details: Optional[List["_models.CloudErrorBodyAutoGenerated"]] = None, **kwargs ): """ @@ -1360,7 +1358,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1407,7 +1405,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1789,7 +1787,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_04_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_04_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1816,18 +1814,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_04_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_04_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1887,11 +1885,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1930,19 +1928,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2053,7 +2051,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_04_01.models.KeyType """ @@ -2071,7 +2069,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -2080,7 +2078,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_04_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -2112,10 +2110,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -2183,8 +2181,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2220,7 +2218,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2272,7 +2270,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocationTypes """ @@ -2285,13 +2283,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2372,9 +2370,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2418,10 +2416,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2432,8 +2430,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2442,14 +2440,13 @@ class FileShare(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2508,10 +2505,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2521,14 +2518,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2577,10 +2574,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2591,8 +2588,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2601,14 +2598,13 @@ class FileShareItem(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2667,10 +2663,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2680,14 +2676,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2755,8 +2751,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2803,7 +2798,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2829,12 +2824,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2869,7 +2864,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2934,7 +2929,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2995,7 +2990,7 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Possible values include: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress", "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_04_01.models.MigrationState """ @@ -3195,7 +3190,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3221,7 +3216,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -3230,7 +3225,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3252,8 +3247,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3283,7 +3278,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3292,7 +3287,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3353,8 +3348,8 @@ class LeaseShareRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3384,7 +3379,7 @@ class LeaseShareRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseShareAction"], + action: Union[str, "_models.LeaseShareAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3393,7 +3388,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3518,7 +3513,7 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, + tags: Optional[List["_models.TagProperty"]] = None, **kwargs ): """ @@ -3614,18 +3609,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3698,9 +3692,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, **kwargs ): """ @@ -3711,7 +3705,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -4001,7 +3995,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -4034,9 +4028,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -4079,9 +4073,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -4129,8 +4123,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -4174,7 +4168,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -4203,7 +4197,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyDefinition @@ -4226,8 +4220,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -4237,7 +4231,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyDefinition @@ -4270,7 +4264,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -4304,9 +4298,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4347,9 +4341,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4410,7 +4404,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4481,8 +4475,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_04_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_04_01.models.ResourceAccessRule] @@ -4491,7 +4485,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_04_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultAction """ @@ -4510,18 +4504,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_04_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4532,7 +4526,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_04_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4557,7 +4551,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4619,7 +4613,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -4710,7 +4704,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -4755,9 +4749,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -4837,7 +4831,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -4895,7 +4889,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionProvisioningState """ @@ -4919,8 +4913,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -4951,7 +4945,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -5030,7 +5024,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -5045,7 +5039,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5064,14 +5058,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5100,7 +5094,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -5146,7 +5140,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -5257,7 +5251,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_04_01.models.ReasonCode """ @@ -5275,14 +5269,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_04_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -5295,7 +5289,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_04_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5314,14 +5308,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_04_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5343,8 +5337,8 @@ class SasPolicy(msrest.serialization.Model): :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Possible values - include: "Log". Default value: "Log". + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :vartype expiration_action: str or ~azure.mgmt.storage.v2021_04_01.models.ExpirationAction """ @@ -5362,14 +5356,14 @@ def __init__( self, *, sas_expiration_period: str, - expiration_action: Union[str, "ExpirationAction"] = "Log", + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Possible - values include: "Log". Default value: "Log". + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_04_01.models.ExpirationAction """ super(SasPolicy, self).__init__(**kwargs) @@ -5385,17 +5379,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5456,10 +5450,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -5479,18 +5473,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5557,7 +5550,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5587,7 +5580,7 @@ def __init__( self, *, id: Optional[str] = None, - access_policy: Optional["AccessPolicy"] = None, + access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): """ @@ -5609,11 +5602,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_04_01.models.SkuTier """ @@ -5631,13 +5624,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName """ @@ -5687,17 +5680,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_04_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5732,14 +5725,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -5786,7 +5779,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -5892,7 +5885,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar identity: The identity of the resource. @@ -5900,7 +5893,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_04_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5909,7 +5902,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_04_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5921,7 +5914,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_04_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5941,7 +5934,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5959,7 +5952,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5975,8 +5968,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6066,15 +6059,15 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, @@ -6099,7 +6092,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6109,8 +6102,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6207,7 +6200,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -6240,7 +6233,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6252,7 +6245,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6262,8 +6255,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6311,25 +6304,25 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, @@ -6338,8 +6331,8 @@ def __init__( """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -6371,7 +6364,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6383,7 +6376,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6393,8 +6386,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6483,8 +6476,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime @@ -6677,8 +6670,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6692,7 +6685,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_04_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6703,7 +6696,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6713,8 +6706,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6750,22 +6743,22 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, **kwargs @@ -6783,8 +6776,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6798,7 +6791,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_04_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6810,7 +6803,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6820,8 +6813,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6936,15 +6929,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_04_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_04_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -6963,25 +6956,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_04_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -7071,7 +7064,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -7188,7 +7181,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7242,7 +7235,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_04_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -7294,7 +7287,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -7380,7 +7373,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "Provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.State """ @@ -7400,7 +7393,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -7410,8 +7403,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_04_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py index ddc0a65da3fc..4ed75f87460f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -26,11 +25,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -40,7 +39,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -51,7 +50,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -61,7 +60,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -70,14 +69,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Default share permission for users using Kerberos authentication if RBAC role is not assigned. """ @@ -87,7 +86,7 @@ class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" STORAGE_FILE_DATA_SMB_SHARE_OWNER = "StorageFileDataSmbShareOwner" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -95,7 +94,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -103,7 +102,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -111,33 +110,33 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExpirationAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SAS expiration action. Can only be Log. """ LOG = "Log" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class Format(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field, it specifies the format for the inventory files. """ CSV = "Csv" PARQUET = "Parquet" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -149,14 +148,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -165,14 +164,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -181,20 +180,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -202,7 +201,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -211,7 +210,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -221,14 +220,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -238,7 +237,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -246,7 +245,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -256,7 +255,7 @@ class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -266,22 +265,22 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. """ @@ -289,7 +288,7 @@ class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IN_PROGRESS = "InProgress" COMPLETED = "Completed" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -298,13 +297,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. """ @@ -312,7 +311,7 @@ class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" CONTAINER = "Container" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -326,7 +325,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -335,7 +334,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -343,7 +342,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -351,7 +350,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -359,7 +358,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -367,7 +366,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -377,7 +376,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -385,27 +384,27 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Schedule(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field is used to schedule an inventory formation. """ DAILY = "Daily" WEEKLY = "Weekly" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -415,7 +414,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -425,7 +424,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -435,7 +434,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -445,7 +444,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -459,14 +458,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -476,12 +475,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py index 60fb849dd95c..0fe8469bf04d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -80,16 +82,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -97,23 +102,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,16 +129,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -143,23 +149,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +177,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -184,21 +192,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -210,9 +216,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -220,16 +228,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -240,16 +247,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -257,23 +267,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -286,16 +294,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -303,23 +314,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -332,18 +341,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -352,25 +364,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -386,11 +396,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -399,23 +413,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -429,11 +441,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -442,22 +458,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -471,10 +485,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -482,22 +500,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -509,16 +525,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -526,24 +545,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -556,16 +573,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -573,23 +593,21 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -603,10 +621,14 @@ def build_object_level_worm_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -614,45 +636,41 @@ def build_object_level_worm_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -663,7 +681,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -675,23 +693,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -699,13 +723,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -713,13 +740,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -733,7 +763,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,7 +780,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -754,9 +788,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -780,13 +814,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -795,14 +833,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -820,7 +865,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -829,9 +874,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -854,13 +899,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -869,14 +918,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,7 +946,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -900,7 +956,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -920,11 +976,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -932,12 +993,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,11 +1019,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -981,11 +1049,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -993,12 +1066,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1008,7 +1088,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -1017,9 +1097,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1043,13 +1123,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1058,14 +1142,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,7 +1170,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1088,9 +1179,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1113,13 +1204,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1128,14 +1223,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1149,7 +1251,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1159,9 +1261,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1179,23 +1281,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1207,15 +1318,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,7 +1351,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1243,7 +1362,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1261,18 +1380,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1280,13 +1409,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1303,7 +1440,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1314,7 +1451,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1336,16 +1473,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1353,13 +1500,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1376,7 +1531,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1387,7 +1542,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1412,11 +1567,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1424,13 +1584,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1447,7 +1614,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1457,9 +1624,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1481,20 +1648,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1506,15 +1677,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1531,7 +1709,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1540,9 +1718,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1558,20 +1736,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1583,14 +1765,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1604,21 +1793,26 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - def _object_level_worm_initial( + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1626,12 +1820,19 @@ def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1641,11 +1842,11 @@ def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( + def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1681,19 +1882,26 @@ def begin_object_level_worm( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._object_level_worm_initial( + raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1703,8 +1911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1713,7 +1927,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py index 6d62e553d8f0..f719d88f7d56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py index ff61f5e3047d..3701f5f85d47 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py index 3fba820c864e..6dc10284acda 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py index 242e624009f8..800cc124e5f7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py index 222f9ce654ac..88fabc70358c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py index 0b8c42cbce79..b61b17fcd38d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,10 +227,14 @@ def build_delete_request( include: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -232,25 +242,23 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,16 +269,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -278,23 +289,21 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -307,17 +316,20 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseShareRequest] = None, content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -325,51 +337,47 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -380,7 +388,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -391,24 +399,30 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -416,13 +430,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -430,13 +447,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,7 +470,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -464,7 +488,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -472,10 +496,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -495,20 +519,24 @@ def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -517,15 +545,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -544,7 +579,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -553,9 +588,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -578,13 +613,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -593,14 +632,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -615,7 +661,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -627,7 +673,7 @@ def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -643,20 +689,26 @@ def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -664,14 +716,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -686,11 +745,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -713,7 +772,7 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -727,11 +786,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -739,14 +803,21 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -757,16 +828,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -790,13 +861,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -805,14 +880,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,7 +905,7 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace @@ -833,9 +915,9 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -851,22 +933,27 @@ def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -878,15 +965,22 @@ def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -904,5 +998,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py index e55f865dbdd3..516e52b97c57 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py index 369c2693e11b..37e6a248834e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -309,11 +329,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -321,12 +346,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,7 +373,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -350,9 +382,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -375,13 +407,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -390,14 +426,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,11 +455,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -442,11 +485,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -454,12 +502,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -470,5 +525,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py index 80ea1bfe9613..0190ffba694b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py index 8d05786da1f2..3d33ad8c0399 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py index eae21c7ca348..a85a982fe8cc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py index df4d020f4105..46875398aaea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -323,7 +340,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -332,9 +349,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -356,13 +373,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -371,14 +392,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -393,7 +421,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -403,7 +431,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -423,11 +451,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -435,12 +468,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -455,11 +495,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -485,11 +525,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -497,12 +542,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -513,7 +565,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -524,7 +576,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -535,21 +587,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -557,12 +614,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -570,12 +630,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -589,7 +652,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,4 +670,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py index d29406d05213..147443fdcd2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py index f26a301d67ff..c0756b3c437d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py index 951c35f2b4df..d00d0f717126 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -494,39 +510,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-04-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -539,56 +556,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -601,26 +617,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -634,23 +661,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -658,14 +689,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -681,7 +719,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -689,9 +727,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -719,35 +757,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -756,13 +806,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -782,23 +831,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -808,7 +869,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -818,7 +879,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -832,31 +893,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -870,7 +943,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -878,9 +951,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -904,13 +977,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -918,14 +995,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -939,14 +1023,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -957,29 +1041,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -993,7 +1088,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1006,14 +1105,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1027,31 +1126,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1065,7 +1175,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1078,7 +1192,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1087,7 +1201,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1098,32 +1212,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1137,7 +1263,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1145,9 +1271,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1166,13 +1292,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1180,14 +1310,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1201,7 +1338,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1209,9 +1346,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1228,13 +1365,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1242,14 +1383,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1263,7 +1411,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1271,9 +1419,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1290,13 +1438,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1304,14 +1456,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1325,32 +1484,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1360,11 +1531,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1393,18 +1564,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1414,8 +1592,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1424,25 +1608,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1450,14 +1637,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1475,7 +1669,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1483,9 +1677,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1510,35 +1704,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1547,13 +1753,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,23 +1778,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1599,5 +1816,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py index ea7e70fe75c6..e5298760cbac 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,7 +309,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -298,7 +319,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -317,11 +338,16 @@ def update( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -329,12 +355,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,7 +382,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -359,7 +392,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -378,11 +411,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -390,12 +428,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,11 +455,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -439,11 +484,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -451,12 +501,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -467,7 +524,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -476,7 +533,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -491,11 +548,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -503,10 +565,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -514,10 +579,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +599,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -545,4 +617,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py index 0bd90dc88417..26314e3c4195 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-04-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py index 938d350529b5..3c54ff25e637 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-04-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_04_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_04_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py index e1898f1fc387..0b960f8a50b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json index 8db940af1b69..fc9fc818b993 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py index d613708a52c9..cea141fe7836 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,8 +73,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -92,30 +96,68 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py index 631e67ed515d..2c8f748487c3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-06-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py index 8912b515f2c8..f7cfd4bca959 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -75,8 +76,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -95,25 +99,63 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py index cfc6a8b47ba0..4e3e22fd0c90 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -57,7 +55,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -69,12 +67,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -82,11 +81,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +98,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +115,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -149,9 +163,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -175,13 +189,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -190,14 +208,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -215,7 +240,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -224,9 +249,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -249,13 +274,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -264,14 +293,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,7 +321,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -295,7 +331,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -315,11 +351,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -327,12 +368,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,11 +394,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -376,11 +424,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -388,12 +441,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -403,7 +463,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -412,9 +472,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -438,13 +498,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -453,14 +517,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,7 +545,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -483,9 +554,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -508,13 +579,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -523,14 +598,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +626,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -554,9 +636,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -574,23 +656,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -602,15 +693,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -627,7 +726,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -638,7 +737,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -656,18 +755,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -675,13 +784,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,7 +815,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -709,7 +826,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -731,16 +848,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -748,13 +875,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,7 +906,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -782,7 +917,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -807,11 +942,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -819,13 +959,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -842,7 +989,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -852,9 +999,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -876,20 +1023,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -901,15 +1052,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,7 +1084,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -935,9 +1093,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -953,20 +1111,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -978,14 +1140,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -999,21 +1168,26 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - async def _object_level_worm_initial( + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1021,12 +1195,19 @@ async def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1036,11 +1217,11 @@ async def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( + async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1076,19 +1257,26 @@ async def begin_object_level_worm( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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")) # 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._object_level_worm_initial( + raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1098,8 +1286,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1108,7 +1302,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py index 9ff36f3f94ee..3ce4f7088a6e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py index 16d106740df1..bf424e27e298 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py index b954fac898f7..9c475c0cac47 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py index aa099fa4ed89..9afb811e3823 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py index 8d1f1a0d7b4f..a8efd54c9524 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py index 025fb3ca1bfb..d620d3224e70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,13 +64,14 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -140,7 +154,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -148,10 +162,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -171,20 +185,24 @@ async def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -193,15 +211,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -220,7 +245,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -229,9 +254,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -254,13 +279,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -269,14 +298,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -291,7 +327,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -303,7 +339,7 @@ async def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -319,20 +355,26 @@ async def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -340,14 +382,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,11 +411,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -389,7 +438,7 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -403,11 +452,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -415,14 +469,21 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -433,16 +494,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -466,13 +527,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -481,14 +546,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -499,7 +571,7 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace_async @@ -509,9 +581,9 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -527,22 +599,27 @@ async def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -554,15 +631,22 @@ async def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -580,5 +664,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py index d5a24b15f07c..5c7da837000c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py index df23468afd4c..112d004426d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -152,11 +165,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -164,12 +182,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +209,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -193,9 +218,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -218,13 +243,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -233,14 +262,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,11 +291,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -285,11 +321,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -297,12 +338,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -313,5 +361,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py index 1b26e3486aac..72a2041dd560 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py index 3716af82c8e4..5f77426cbbfb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py index 97bca9a0194e..252b6a0cc627 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py index 52d4d2f5f398..e919bdb0ddd6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,7 +122,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -122,9 +131,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -146,13 +155,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -161,14 +174,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,7 +203,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -193,7 +213,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -213,11 +233,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -225,12 +250,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,11 +277,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -275,11 +307,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -287,12 +324,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -303,7 +347,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -314,7 +358,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -325,10 +369,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -336,11 +380,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -348,12 +397,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -361,12 +413,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -380,7 +435,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,4 +453,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py index f804cdbadbfb..946572fc3453 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py index 4a9347058826..66012f9ed807 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py index 79b6bac23f8e..0586c28e08d5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -26,34 +26,32 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_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")) # 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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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")) # 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._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,36 +1056,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - async def _hierarchical_namespace_migration_initial( + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -929,11 +1106,11 @@ async def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( + async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -966,19 +1143,26 @@ async def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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")) # 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._hierarchical_namespace_migration_initial( + raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -988,8 +1172,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -998,34 +1188,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - async def _abort_hierarchical_namespace_migration_initial( + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1035,11 +1236,11 @@ async def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1066,18 +1267,25 @@ async def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _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")) # 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._abort_hierarchical_namespace_migration_initial( + raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1087,8 +1295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1097,25 +1311,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1123,14 +1340,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1148,7 +1372,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -1156,9 +1380,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1184,35 +1408,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_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")) # 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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1221,13 +1457,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1247,23 +1482,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1273,5 +1520,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py index 67f077bd90d6..eb08ed4751c2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -114,7 +124,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,11 +143,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -145,12 +160,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -165,7 +187,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -175,7 +197,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -194,11 +216,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -206,12 +233,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -226,11 +260,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -255,11 +289,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -267,12 +306,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -283,7 +329,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -292,7 +338,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -308,11 +354,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -320,10 +371,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -331,10 +385,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -348,7 +405,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -362,4 +423,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py index 883e0ff08850..2ebb110ba266 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,7 +106,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -104,9 +114,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -120,18 +130,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -139,14 +158,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,7 +188,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -170,7 +197,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -181,28 +208,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,5 +262,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py index fda99797eccd..e7deccd855fb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py index 404e980009f7..cac552f15595 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py @@ -211,7 +211,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccessPolicy', 'AccountImmutabilityPolicyProperties', @@ -415,3 +417,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py index ce59dceddf5f..e8ef4643dd7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessPolicy(msrest.serialization.Model): @@ -65,7 +67,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and @@ -89,7 +91,7 @@ def __init__( self, *, immutability_period_since_creation_in_days: Optional[int] = None, - state: Optional[Union[str, "AccountImmutabilityPolicyState"]] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, allow_protected_append_writes: Optional[bool] = None, **kwargs ): @@ -102,7 +104,7 @@ def __init__( and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and @@ -123,22 +125,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_06_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -170,35 +172,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_06_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -378,15 +379,15 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_06_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. :vartype active_directory_properties: ~azure.mgmt.storage.v2021_06_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or @@ -406,21 +407,21 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, - default_share_permission: Optional[Union[str, "DefaultSharePermission"]] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_06_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_06_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or @@ -462,18 +463,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -552,9 +552,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -567,7 +567,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -644,7 +644,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -666,14 +666,13 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyFilter :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_06_01.models.Format :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Possible values include: "Daily", "Weekly". + formation. Known values are: "Daily", "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_06_01.models.Schedule :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_06_01.models.ObjectType :ivar schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -706,25 +705,24 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - format: Union[str, "Format"], - schedule: Union[str, "Schedule"], - object_type: Union[str, "ObjectType"], + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], schema_fields: List[str], - filters: Optional["BlobInventoryPolicyFilter"] = None, + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, **kwargs ): """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyFilter :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_06_01.models.Format :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Possible values include: "Daily", "Weekly". + inventory formation. Known values are: "Daily", "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_06_01.models.Schedule :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_06_01.models.ObjectType :keyword schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -841,7 +839,7 @@ def __init__( enabled: bool, name: str, destination: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -870,7 +868,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar enabled: Required. Policy is enabled if set to true. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -893,14 +891,14 @@ def __init__( self, *, enabled: bool, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ :keyword enabled: Required. Policy is enabled if set to true. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -937,7 +935,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -997,8 +995,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1130,15 +1128,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1234,7 +1232,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1279,7 +1277,7 @@ class CloudErrorAutoGenerated(msrest.serialization.Model): def __init__( self, *, - error: Optional["CloudErrorBodyAutoGenerated"] = None, + error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, **kwargs ): """ @@ -1319,7 +1317,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1371,7 +1369,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBodyAutoGenerated"]] = None, + details: Optional[List["_models.CloudErrorBodyAutoGenerated"]] = None, **kwargs ): """ @@ -1437,7 +1435,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1484,7 +1482,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1866,7 +1864,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_06_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_06_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1893,18 +1891,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_06_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_06_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1964,11 +1962,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -2007,19 +2005,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2130,7 +2128,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_06_01.models.KeyType """ @@ -2148,7 +2146,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -2157,7 +2155,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_06_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -2189,10 +2187,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -2260,8 +2258,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2297,7 +2295,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2349,7 +2347,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocationTypes """ @@ -2362,13 +2360,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2449,9 +2447,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2495,10 +2493,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2509,8 +2507,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2519,14 +2517,13 @@ class FileShare(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2585,10 +2582,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2598,14 +2595,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2654,10 +2651,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2668,8 +2665,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2678,14 +2675,13 @@ class FileShareItem(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2744,10 +2740,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2757,14 +2753,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2832,8 +2828,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2880,7 +2875,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2906,12 +2901,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2946,7 +2941,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3028,7 +3023,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3119,7 +3114,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - immutability_policy: Optional["AccountImmutabilityPolicyProperties"] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, **kwargs ): """ @@ -3150,7 +3145,7 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Possible values include: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress", "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_06_01.models.MigrationState """ @@ -3350,7 +3345,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3376,7 +3371,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -3385,7 +3380,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3407,8 +3402,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3438,7 +3433,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3447,7 +3442,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3508,8 +3503,8 @@ class LeaseShareRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3539,7 +3534,7 @@ class LeaseShareRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseShareAction"], + action: Union[str, "_models.LeaseShareAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3548,7 +3543,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3688,8 +3683,8 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, - protected_append_writes_history: Optional["ProtectedAppendWritesHistory"] = None, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, **kwargs ): """ @@ -3789,18 +3784,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3879,9 +3873,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -3894,7 +3888,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -4190,7 +4184,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -4223,9 +4217,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -4268,9 +4262,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -4318,8 +4312,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -4363,7 +4357,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -4392,7 +4386,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyDefinition @@ -4415,8 +4409,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -4426,7 +4420,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyDefinition @@ -4459,7 +4453,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -4493,9 +4487,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4536,9 +4530,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4599,7 +4593,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4670,8 +4664,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_06_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_06_01.models.ResourceAccessRule] @@ -4680,7 +4674,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_06_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultAction """ @@ -4699,18 +4693,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_06_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4721,7 +4715,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_06_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4746,7 +4740,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4808,7 +4802,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -4899,7 +4893,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -4944,9 +4938,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -5026,7 +5020,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -5084,7 +5078,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionProvisioningState """ @@ -5108,8 +5102,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -5140,7 +5134,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -5219,7 +5213,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -5234,7 +5228,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5253,14 +5247,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5328,7 +5322,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -5374,7 +5368,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -5485,7 +5479,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_06_01.models.ReasonCode """ @@ -5503,14 +5497,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_06_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -5523,7 +5517,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_06_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5542,14 +5536,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_06_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5571,8 +5565,8 @@ class SasPolicy(msrest.serialization.Model): :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Possible values - include: "Log". Default value: "Log". + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :vartype expiration_action: str or ~azure.mgmt.storage.v2021_06_01.models.ExpirationAction """ @@ -5590,14 +5584,14 @@ def __init__( self, *, sas_expiration_period: str, - expiration_action: Union[str, "ExpirationAction"] = "Log", + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Possible - values include: "Log". Default value: "Log". + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_06_01.models.ExpirationAction """ super(SasPolicy, self).__init__(**kwargs) @@ -5613,17 +5607,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5684,10 +5678,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -5707,18 +5701,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5785,7 +5778,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -5815,7 +5808,7 @@ def __init__( self, *, id: Optional[str] = None, - access_policy: Optional["AccessPolicy"] = None, + access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): """ @@ -5837,11 +5830,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_06_01.models.SkuTier """ @@ -5859,13 +5852,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName """ @@ -5915,17 +5908,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5960,14 +5953,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -6014,7 +6007,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -6120,7 +6113,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar identity: The identity of the resource. @@ -6128,7 +6121,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6137,7 +6130,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6149,7 +6142,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6169,7 +6162,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6187,7 +6180,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6203,8 +6196,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6220,8 +6213,8 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -6310,21 +6303,21 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, **kwargs ): """ @@ -6346,7 +6339,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6356,8 +6349,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6373,7 +6366,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -6470,7 +6463,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -6490,8 +6483,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :ivar sas_policy: SasPolicy assigned to the storage account. @@ -6508,7 +6501,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6520,7 +6513,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6530,8 +6523,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6590,38 +6583,38 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -6640,7 +6633,7 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -6658,7 +6651,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6670,7 +6663,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6680,8 +6673,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6781,8 +6774,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime @@ -6975,8 +6968,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6990,7 +6983,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_06_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7001,7 +6994,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7011,8 +7004,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7026,8 +7019,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -7064,27 +7057,27 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, **kwargs ): """ @@ -7100,8 +7093,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7115,7 +7108,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_06_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7127,7 +7120,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7137,8 +7130,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7152,7 +7145,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -7269,15 +7262,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_06_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_06_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -7296,25 +7289,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_06_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_06_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -7404,7 +7397,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -7521,7 +7514,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7608,7 +7601,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -7660,7 +7653,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -7746,7 +7739,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "Provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.State """ @@ -7766,7 +7759,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -7776,8 +7769,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py index c7bf893a88f0..12c5d9f67712 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of @@ -31,7 +30,7 @@ class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str LOCKED = "Locked" DISABLED = "Disabled" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -39,11 +38,11 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -53,7 +52,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -64,7 +63,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -74,7 +73,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -83,14 +82,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Default share permission for users using Kerberos authentication if RBAC role is not assigned. """ @@ -99,7 +98,7 @@ class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -107,7 +106,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -115,7 +114,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -123,33 +122,33 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExpirationAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SAS expiration action. Can only be Log. """ LOG = "Log" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class Format(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field, it specifies the format for the inventory files. """ CSV = "Csv" PARQUET = "Parquet" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -161,14 +160,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -177,14 +176,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -193,20 +192,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -214,7 +213,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -223,7 +222,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -233,14 +232,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -250,7 +249,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -258,7 +257,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -268,7 +267,7 @@ class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -278,22 +277,22 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. """ @@ -301,7 +300,7 @@ class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IN_PROGRESS = "InProgress" COMPLETED = "Completed" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -310,13 +309,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. """ @@ -324,7 +323,7 @@ class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" CONTAINER = "Container" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -338,7 +337,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -347,7 +346,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -355,7 +354,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -363,7 +362,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -371,7 +370,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. """ @@ -379,7 +378,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -387,7 +386,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -397,7 +396,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -405,27 +404,27 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Schedule(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field is used to schedule an inventory formation. """ DAILY = "Daily" WEEKLY = "Weekly" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -435,7 +434,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -445,7 +444,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -455,7 +454,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -465,7 +464,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -479,14 +478,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -496,12 +495,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py index bddcf8c8cb34..9a63fd415725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py @@ -26,6 +26,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -47,3 +50,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py index f16c3dc94210..a67ce07b6113 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -80,16 +82,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -97,23 +102,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,16 +129,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -143,23 +149,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +177,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -184,21 +192,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -210,9 +216,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -220,16 +228,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -240,16 +247,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -257,23 +267,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -286,16 +294,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -303,23 +314,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -332,18 +341,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -352,25 +364,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -386,11 +396,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -399,23 +413,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -429,11 +441,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -442,22 +458,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -471,10 +485,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -482,22 +500,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -509,16 +525,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -526,24 +545,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -556,16 +573,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -573,23 +593,21 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -603,10 +621,14 @@ def build_object_level_worm_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -614,45 +636,41 @@ def build_object_level_worm_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -663,7 +681,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -675,23 +693,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -699,13 +723,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -713,13 +740,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -733,7 +763,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,7 +780,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -754,9 +788,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -780,13 +814,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -795,14 +833,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -820,7 +865,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -829,9 +874,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -854,13 +899,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -869,14 +918,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,7 +946,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -900,7 +956,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -920,11 +976,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -932,12 +993,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,11 +1019,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -981,11 +1049,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -993,12 +1066,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1008,7 +1088,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -1017,9 +1097,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1043,13 +1123,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1058,14 +1142,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,7 +1170,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1088,9 +1179,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1113,13 +1204,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1128,14 +1223,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1149,7 +1251,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1159,9 +1261,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1179,23 +1281,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1207,15 +1318,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,7 +1351,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1243,7 +1362,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1261,18 +1380,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1280,13 +1409,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1303,7 +1440,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1314,7 +1451,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1336,16 +1473,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1353,13 +1500,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1376,7 +1531,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1387,7 +1542,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1412,11 +1567,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1424,13 +1584,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1447,7 +1614,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1457,9 +1624,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1481,20 +1648,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1506,15 +1677,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1531,7 +1709,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1540,9 +1718,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1558,20 +1736,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1583,14 +1765,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1604,21 +1793,26 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - def _object_level_worm_initial( + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1626,12 +1820,19 @@ def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1641,11 +1842,11 @@ def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( + def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1681,19 +1882,26 @@ def begin_object_level_worm( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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")) # 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._object_level_worm_initial( + raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1703,8 +1911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1713,7 +1927,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py index 8a6e99de0948..0cacc54f5511 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py index c2a029a73f78..0590d72ac237 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py index 029c9f3ed70c..d5bf59ffacbf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py index cf406394332b..ea4e8b99fc12 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py index 5964741f8bb8..0c928451c2f4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py index 55796ddcd1d8..ec4819cec2b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,10 +227,14 @@ def build_delete_request( include: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -232,25 +242,23 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,16 +269,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -278,23 +289,21 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -307,17 +316,20 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseShareRequest] = None, content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -325,51 +337,47 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -380,7 +388,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -391,24 +399,30 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -416,13 +430,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -430,13 +447,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,7 +470,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -464,7 +488,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -472,10 +496,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -495,20 +519,24 @@ def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -517,15 +545,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -544,7 +579,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -553,9 +588,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -578,13 +613,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -593,14 +632,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -615,7 +661,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -627,7 +673,7 @@ def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -643,20 +689,26 @@ def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -664,14 +716,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -686,11 +745,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -713,7 +772,7 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -727,11 +786,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -739,14 +803,21 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -757,16 +828,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -790,13 +861,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -805,14 +880,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -823,7 +905,7 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace @@ -833,9 +915,9 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -851,22 +933,27 @@ def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -878,15 +965,22 @@ def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -904,5 +998,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py index c65577caeb41..ffba69a28298 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py index 42e6a669abc9..9b6acecffee4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -309,11 +329,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -321,12 +346,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,7 +373,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -350,9 +382,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -375,13 +407,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -390,14 +426,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,11 +455,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -442,11 +485,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -454,12 +502,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -470,5 +525,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py index 9e6aa0fb98b3..fe318d413696 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py index a377f6f1db2b..c2cb8ab73d74 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _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")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py index 346a15ac4494..cd7ddbe8d21d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py index 78bffb87257a..dcc7ed1805f5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -323,7 +340,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -332,9 +349,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -356,13 +373,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -371,14 +392,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -393,7 +421,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -403,7 +431,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -423,11 +451,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -435,12 +468,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -455,11 +495,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -485,11 +525,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -497,12 +542,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -513,7 +565,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -524,7 +576,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -535,21 +587,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -557,12 +614,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -570,12 +630,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -589,7 +652,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,4 +670,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py index 9d40d5eecd71..3695d3d020da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py index 48e515451231..80ca5b61ace1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py index b45cb5fb1a01..e24bb747b506 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -497,32 +513,34 @@ def build_hierarchical_namespace_migration_request_initial( request_type: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -533,31 +551,33 @@ def build_abort_hierarchical_namespace_migration_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -567,39 +587,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -612,56 +633,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -674,26 +694,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,23 +738,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -731,14 +766,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -754,7 +796,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +804,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -792,35 +834,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_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")) # 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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -829,13 +883,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -855,23 +908,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -881,7 +946,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -891,7 +956,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -905,31 +970,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,7 +1020,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -951,9 +1028,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -977,13 +1054,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -991,14 +1072,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1012,14 +1100,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1030,29 +1118,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1066,7 +1165,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,14 +1182,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1100,31 +1203,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1138,7 +1252,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1151,7 +1269,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1160,7 +1278,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1171,32 +1289,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1340,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1218,9 +1348,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1239,13 +1369,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1253,14 +1387,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1274,7 +1415,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1282,9 +1423,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1301,13 +1442,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1315,14 +1460,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1336,7 +1488,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1344,9 +1496,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1363,13 +1515,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1377,14 +1533,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1398,32 +1561,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1433,11 +1608,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1466,18 +1641,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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")) # 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._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1487,8 +1669,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1497,36 +1685,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - def _hierarchical_namespace_migration_initial( + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1536,11 +1735,11 @@ def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( + def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,19 +1772,26 @@ def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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")) # 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._hierarchical_namespace_migration_initial( + raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1595,8 +1801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1605,34 +1817,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - def _abort_hierarchical_namespace_migration_initial( + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1642,11 +1865,11 @@ def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1673,18 +1896,25 @@ def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _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")) # 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._abort_hierarchical_namespace_migration_initial( + raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1694,8 +1924,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1704,25 +1940,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1730,14 +1969,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1755,7 +2001,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1763,9 +2009,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1790,35 +2036,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_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")) # 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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1827,13 +2085,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1853,23 +2110,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1879,5 +2148,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py index b4a4a5ba0f30..13a6678cde56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,7 +309,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -298,7 +319,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -317,11 +338,16 @@ def update( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -329,12 +355,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -349,7 +382,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -359,7 +392,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -378,11 +411,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -390,12 +428,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -410,11 +455,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -439,11 +484,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -451,12 +501,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -467,7 +524,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -476,7 +533,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -491,11 +548,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -503,10 +565,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -514,10 +579,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +599,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -545,4 +617,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py index 655e68cc94af..bf081f5a8a3b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-06-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -217,7 +232,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -225,9 +240,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -241,18 +256,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -260,14 +284,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -282,7 +314,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -291,7 +323,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -302,28 +334,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _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")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,5 +388,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py index 41f7400375df..734198914c3f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_06_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_06_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _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")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py index 208223817180..1eb91a925ec3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json index 692b8bf846e4..2fe0e6c61c67 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py index 83125fc3fe19..fd8b1be60d8d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -74,8 +75,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -94,31 +98,71 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py index b9ef2874d493..0200f3c9da50 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-08-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-08-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py index e2ecd0cc2d91..70166161a2d2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -77,8 +78,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-08-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -97,26 +101,66 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py index 4c1064ae3825..22f9808d440a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py @@ -27,6 +27,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -49,3 +52,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py index 0b592eaecc83..cd30eb60675b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -57,7 +55,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -69,12 +67,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -82,11 +81,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +98,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +115,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -149,9 +163,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -175,13 +189,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -190,14 +208,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -215,7 +240,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -224,9 +249,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -249,13 +274,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -264,14 +293,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,7 +321,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -295,7 +331,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -315,11 +351,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -327,12 +368,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,11 +394,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -376,11 +424,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -388,12 +441,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -403,7 +463,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -412,9 +472,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -438,13 +498,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -453,14 +517,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,7 +545,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -483,9 +554,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -508,13 +579,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -523,14 +598,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +626,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -554,9 +636,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -574,23 +656,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -602,15 +693,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -627,7 +726,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -638,7 +737,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -656,18 +755,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -675,13 +784,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,7 +815,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -709,7 +826,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -731,16 +848,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -748,13 +875,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,7 +906,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -782,7 +917,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -807,11 +942,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -819,13 +959,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -842,7 +989,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -852,9 +999,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -876,20 +1023,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -901,15 +1052,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,7 +1084,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -935,9 +1093,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -953,20 +1111,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -978,14 +1140,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -999,21 +1168,26 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - async def _object_level_worm_initial( + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1021,12 +1195,19 @@ async def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1036,11 +1217,11 @@ async def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( + async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1076,19 +1257,26 @@ async def begin_object_level_worm( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._object_level_worm_initial( + raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1098,8 +1286,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1108,7 +1302,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py index e4a42e31c1a8..13020e1dc0f1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,7 +114,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -113,9 +123,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -136,13 +146,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -151,14 +165,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -173,11 +194,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -202,11 +223,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -214,12 +240,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -230,7 +263,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -239,7 +272,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +289,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,10 +306,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -279,10 +320,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -296,7 +340,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -310,4 +358,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py index 7ecab227437f..f9062d91d543 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py index 875555253183..4a6ded96099f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py index e7e94ff541f0..4432d4a78ef1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py index acafd0a2e1c3..118124f3b4d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py index 8d01220bc8e3..358669b19aa2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,13 +64,14 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -147,10 +161,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -170,20 +184,24 @@ async def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -192,15 +210,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,7 +243,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -227,9 +252,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -252,13 +277,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -267,14 +296,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,7 +324,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -300,7 +336,7 @@ async def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,20 +352,26 @@ async def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -337,14 +379,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,11 +407,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -385,7 +434,7 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -399,11 +448,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -411,14 +465,21 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -428,16 +489,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -461,13 +522,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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[None] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -476,14 +541,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -493,7 +565,7 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace_async @@ -503,9 +575,9 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -521,22 +593,27 @@ async def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -548,15 +625,22 @@ async def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -573,5 +657,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py index c8d8586e7753..215a0d505182 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LocalUsersOperations: - """LocalUsersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`local_users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LocalUsers"]: + ) -> AsyncIterable[_models.LocalUsers]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUsers"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: "_models.LocalUser", + properties: _models.LocalUser, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LocalUser] _json = self._serialize.body(properties, 'LocalUser') @@ -227,14 +256,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,7 +353,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async @@ -315,7 +363,7 @@ async def list_keys( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserKeys": + ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -333,11 +381,16 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] request = build_list_keys_request( @@ -345,12 +398,19 @@ async def list_keys( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -365,7 +425,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace_async @@ -375,7 +435,7 @@ async def regenerate_password( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserRegeneratePasswordResult": + ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -393,11 +453,16 @@ async def regenerate_password( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserRegeneratePasswordResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] request = build_regenerate_password_request( @@ -405,12 +470,19 @@ async def regenerate_password( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.regenerate_password.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -425,5 +497,5 @@ async def regenerate_password( return deserialized - regenerate_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword'} # type: ignore + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py index 523ba744852d..df7cd03b7e22 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py index 2ea172cbd9d8..655bbd755a4d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -152,11 +165,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -164,12 +182,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +209,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -193,9 +218,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -218,13 +243,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -233,14 +262,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,11 +291,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -285,11 +321,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -297,12 +338,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -313,5 +361,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py index a5a3d08a508a..935e67a6107c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py index a7c1b64f9ba1..ba79a8065ff9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py index 9f0a1e6b0627..20eef9671813 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py index 2856082d76a1..be32f7e40c76 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py index d126b13d7367..dc655d36f50e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py index 7f43ce87fd72..aaba7b75630d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py index aab0bf562ff0..533da9740361 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -26,34 +26,32 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,36 +1056,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - async def _hierarchical_namespace_migration_initial( + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -929,11 +1106,11 @@ async def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( + async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -966,19 +1143,26 @@ async def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._hierarchical_namespace_migration_initial( + raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -988,8 +1172,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -998,34 +1188,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - async def _abort_hierarchical_namespace_migration_initial( + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1035,11 +1236,11 @@ async def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1066,18 +1267,25 @@ async def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = await self._abort_hierarchical_namespace_migration_initial( + raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1087,8 +1295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1097,25 +1311,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1123,14 +1340,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1148,7 +1372,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -1156,9 +1380,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1184,35 +1408,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1221,13 +1457,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1247,23 +1482,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1273,5 +1520,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py index 2aedbdba78be..01d7321aab4b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -53,7 +51,7 @@ async def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -84,12 +87,19 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -113,7 +123,7 @@ async def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -132,11 +142,16 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -144,12 +159,19 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -163,7 +185,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -173,7 +195,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -192,11 +214,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -204,12 +231,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -223,11 +257,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -252,11 +286,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -264,12 +303,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -279,7 +325,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -288,7 +334,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -304,11 +350,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -316,10 +367,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -327,10 +381,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -344,7 +401,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -357,4 +418,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py index 8e916d4ffb13..dd94f24cedb5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py index 3c7ee089fbf7..9fb8e3b05185 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py index b5011a2b04b5..17ffc8c85bb4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py @@ -217,7 +217,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccessPolicy', 'AccountImmutabilityPolicyProperties', @@ -427,3 +429,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py index 46c641b79cb6..028df747ec12 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessPolicy(msrest.serialization.Model): @@ -65,7 +67,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and @@ -89,7 +91,7 @@ def __init__( self, *, immutability_period_since_creation_in_days: Optional[int] = None, - state: Optional[Union[str, "AccountImmutabilityPolicyState"]] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, allow_protected_append_writes: Optional[bool] = None, **kwargs ): @@ -102,7 +104,7 @@ def __init__( and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and @@ -123,22 +125,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_08_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -170,35 +172,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_08_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -239,8 +240,8 @@ class ActiveDirectoryProperties(msrest.serialization.Model): :vartype azure_storage_sid: str :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :vartype sam_account_name: str - :ivar account_type: Specifies the Active Directory account type for Azure Storage. Possible - values include: "User", "Computer". + :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values + are: "User", "Computer". :vartype account_type: str or ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryPropertiesAccountType """ @@ -275,7 +276,7 @@ def __init__( domain_sid: str, azure_storage_sid: str, sam_account_name: Optional[str] = None, - account_type: Optional[Union[str, "ActiveDirectoryPropertiesAccountType"]] = None, + account_type: Optional[Union[str, "_models.ActiveDirectoryPropertiesAccountType"]] = None, **kwargs ): """ @@ -295,8 +296,8 @@ def __init__( :paramtype azure_storage_sid: str :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :paramtype sam_account_name: str - :keyword account_type: Specifies the Active Directory account type for Azure Storage. Possible - values include: "User", "Computer". + :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known + values are: "User", "Computer". :paramtype account_type: str or ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryPropertiesAccountType """ @@ -396,15 +397,15 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_08_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. :vartype active_directory_properties: ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or @@ -424,21 +425,21 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, - default_share_permission: Optional[Union[str, "DefaultSharePermission"]] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_08_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or @@ -480,18 +481,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -570,9 +570,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -585,7 +585,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -662,7 +662,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -684,14 +684,13 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyFilter :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_08_01.models.Format :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Possible values include: "Daily", "Weekly". + formation. Known values are: "Daily", "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_08_01.models.Schedule :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_08_01.models.ObjectType :ivar schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -724,25 +723,24 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - format: Union[str, "Format"], - schedule: Union[str, "Schedule"], - object_type: Union[str, "ObjectType"], + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], schema_fields: List[str], - filters: Optional["BlobInventoryPolicyFilter"] = None, + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, **kwargs ): """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyFilter :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_08_01.models.Format :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Possible values include: "Daily", "Weekly". + inventory formation. Known values are: "Daily", "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_08_01.models.Schedule :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_08_01.models.ObjectType :keyword schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -859,7 +857,7 @@ def __init__( enabled: bool, name: str, destination: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -888,7 +886,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar enabled: Required. Policy is enabled if set to true. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -911,14 +909,14 @@ def __init__( self, *, enabled: bool, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ :keyword enabled: Required. Policy is enabled if set to true. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -955,7 +953,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -1015,8 +1013,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1148,15 +1146,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1252,7 +1250,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_08_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1312,7 +1310,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1378,7 +1376,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1425,7 +1423,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1807,7 +1805,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_08_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_08_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1834,18 +1832,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_08_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_08_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1916,11 +1914,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1959,19 +1957,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2081,7 +2079,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_08_01.models.KeyType """ @@ -2099,7 +2097,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -2108,7 +2106,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_08_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -2140,10 +2138,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -2211,8 +2209,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2248,7 +2246,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2300,7 +2298,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocationTypes """ @@ -2313,13 +2311,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2400,9 +2398,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2446,10 +2444,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2460,8 +2458,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2470,14 +2468,13 @@ class FileShare(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2536,10 +2533,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2549,14 +2546,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2605,10 +2602,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2619,8 +2616,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2629,14 +2626,13 @@ class FileShareItem(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2695,10 +2691,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2708,14 +2704,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2783,8 +2779,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2831,7 +2826,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2857,12 +2852,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2897,7 +2892,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2979,7 +2974,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3070,7 +3065,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - immutability_policy: Optional["AccountImmutabilityPolicyProperties"] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, **kwargs ): """ @@ -3101,7 +3096,7 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Possible values include: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress", "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_08_01.models.MigrationState """ @@ -3301,7 +3296,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3327,7 +3322,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -3336,7 +3331,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3358,8 +3353,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3389,7 +3384,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3398,7 +3393,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3459,8 +3454,8 @@ class LeaseShareRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3490,7 +3485,7 @@ class LeaseShareRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseShareAction"], + action: Union[str, "_models.LeaseShareAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3499,7 +3494,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3639,8 +3634,8 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, - protected_append_writes_history: Optional["ProtectedAppendWritesHistory"] = None, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, **kwargs ): """ @@ -3740,18 +3735,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3830,9 +3824,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -3845,7 +3839,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -4162,9 +4156,9 @@ class LocalUser(Resource): def __init__( self, *, - permission_scopes: Optional[List["PermissionScope"]] = None, + permission_scopes: Optional[List["_models.PermissionScope"]] = None, home_directory: Optional[str] = None, - ssh_authorized_keys: Optional[List["SshPublicKey"]] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, has_shared_key: Optional[bool] = None, has_ssh_key: Optional[bool] = None, has_ssh_password: Optional[bool] = None, @@ -4221,7 +4215,7 @@ class LocalUserKeys(msrest.serialization.Model): def __init__( self, *, - ssh_authorized_keys: Optional[List["SshPublicKey"]] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -4275,7 +4269,7 @@ class LocalUsers(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LocalUser"]] = None, + value: Optional[List["_models.LocalUser"]] = None, **kwargs ): """ @@ -4324,7 +4318,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -4357,9 +4351,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -4402,9 +4396,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -4452,8 +4446,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -4497,7 +4491,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -4526,7 +4520,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyDefinition @@ -4549,8 +4543,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -4560,7 +4554,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyDefinition @@ -4593,7 +4587,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -4627,9 +4621,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4670,9 +4664,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4733,7 +4727,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4804,8 +4798,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_08_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_08_01.models.ResourceAccessRule] @@ -4814,7 +4808,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_08_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultAction """ @@ -4833,18 +4827,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_08_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4855,7 +4849,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_08_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4880,7 +4874,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -4942,7 +4936,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -5033,7 +5027,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -5078,9 +5072,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -5160,7 +5154,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -5269,7 +5263,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionProvisioningState """ @@ -5293,8 +5287,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -5325,7 +5319,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -5404,7 +5398,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -5419,7 +5413,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5438,14 +5432,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5513,7 +5507,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -5559,7 +5553,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -5670,7 +5664,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_08_01.models.ReasonCode """ @@ -5688,14 +5682,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_08_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -5708,7 +5702,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_08_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5727,14 +5721,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_08_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5756,8 +5750,8 @@ class SasPolicy(msrest.serialization.Model): :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Possible values - include: "Log". Default value: "Log". + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :vartype expiration_action: str or ~azure.mgmt.storage.v2021_08_01.models.ExpirationAction """ @@ -5775,14 +5769,14 @@ def __init__( self, *, sas_expiration_period: str, - expiration_action: Union[str, "ExpirationAction"] = "Log", + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Possible - values include: "Log". Default value: "Log". + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_08_01.models.ExpirationAction """ super(SasPolicy, self).__init__(**kwargs) @@ -5798,17 +5792,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5869,10 +5863,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -5892,18 +5886,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5970,7 +5963,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -6000,7 +5993,7 @@ def __init__( self, *, id: Optional[str] = None, - access_policy: Optional["AccessPolicy"] = None, + access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): """ @@ -6022,11 +6015,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_08_01.models.SkuTier """ @@ -6044,13 +6037,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName """ @@ -6100,17 +6093,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_08_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -6145,14 +6138,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -6199,7 +6192,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -6339,7 +6332,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar identity: The identity of the resource. @@ -6347,7 +6340,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_08_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6356,7 +6349,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_08_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6368,7 +6361,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_08_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6388,7 +6381,7 @@ class StorageAccount(TrackedResource): account. :vartype encryption: ~azure.mgmt.storage.v2021_08_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6410,7 +6403,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6426,8 +6419,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6443,8 +6436,8 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -6453,7 +6446,7 @@ class StorageAccount(TrackedResource): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ @@ -6539,24 +6532,24 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, **kwargs ): """ @@ -6582,7 +6575,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6592,8 +6585,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6609,7 +6602,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -6619,7 +6612,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) @@ -6712,7 +6705,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -6732,11 +6725,11 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :ivar sas_policy: SasPolicy assigned to the storage account. @@ -6753,7 +6746,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6769,7 +6762,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6779,8 +6772,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6842,41 +6835,41 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -6895,10 +6888,10 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -6916,7 +6909,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6932,7 +6925,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6942,8 +6935,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7046,8 +7039,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime @@ -7240,8 +7233,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7255,7 +7248,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_08_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Possible values include: "Hot", "Cool". + for billing. Known values are: "Hot", "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7270,7 +7263,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7280,8 +7273,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7295,8 +7288,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -7305,7 +7298,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ @@ -7339,30 +7332,30 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, **kwargs ): """ @@ -7378,8 +7371,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7393,7 +7386,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_08_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Possible values include: "Hot", "Cool". + used for billing. Known values are: "Hot", "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7409,7 +7402,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7419,8 +7412,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7434,7 +7427,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -7444,7 +7437,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ super(StorageAccountUpdateParameters, self).__init__(**kwargs) @@ -7557,15 +7550,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_08_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_08_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -7584,25 +7577,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_08_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_08_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -7692,7 +7685,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -7809,7 +7802,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7896,7 +7889,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_08_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -7948,7 +7941,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -8034,7 +8027,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "Provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.State """ @@ -8054,7 +8047,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -8064,8 +8057,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py index 343311c70233..94d2e110787f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier used for billing. """ HOT = "Hot" COOL = "Cool" -class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of @@ -31,7 +30,7 @@ class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str LOCKED = "Locked" DISABLED = "Disabled" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -39,14 +38,14 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class ActiveDirectoryPropertiesAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ActiveDirectoryPropertiesAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the Active Directory account type for Azure Storage. """ USER = "User" COMPUTER = "Computer" -class AllowedCopyScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. """ @@ -54,11 +53,11 @@ class AllowedCopyScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIVATE_LINK = "PrivateLink" AAD = "AAD" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -68,7 +67,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -79,7 +78,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -89,7 +88,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En OPTIONS = "OPTIONS" PUT = "PUT" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -98,14 +97,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Default share permission for users using Kerberos authentication if RBAC role is not assigned. """ @@ -114,7 +113,7 @@ class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -122,7 +121,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -130,7 +129,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -138,33 +137,33 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExpirationAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SAS expiration action. Can only be Log. """ LOG = "Log" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class Format(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field, it specifies the format for the inventory files. """ CSV = "Csv" PARQUET = "Parquet" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -176,14 +175,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -192,14 +191,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -208,20 +207,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -229,7 +228,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -238,7 +237,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -248,14 +247,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -265,7 +264,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -273,7 +272,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -283,7 +282,7 @@ class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -293,22 +292,22 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. """ @@ -316,7 +315,7 @@ class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IN_PROGRESS = "InProgress" COMPLETED = "Completed" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -325,13 +324,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. """ @@ -339,7 +338,7 @@ class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" CONTAINER = "Container" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -353,7 +352,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -362,7 +361,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -370,7 +369,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -378,7 +377,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -386,7 +385,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. """ @@ -394,7 +393,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -402,7 +401,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -412,7 +411,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -420,27 +419,27 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Schedule(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field is used to schedule an inventory formation. """ DAILY = "Daily" WEEKLY = "Weekly" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -450,7 +449,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -460,7 +459,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -470,7 +469,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -480,7 +479,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -494,14 +493,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -511,12 +510,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py index 4c1064ae3825..22f9808d440a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py @@ -27,6 +27,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -49,3 +52,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py index 2880c2b81dd9..71d3e64fdd7a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -80,16 +82,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -97,23 +102,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,16 +129,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -143,23 +149,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +177,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -184,21 +192,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -210,9 +216,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -220,16 +228,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -240,16 +247,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -257,23 +267,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -286,16 +294,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -303,23 +314,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -332,18 +341,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -352,25 +364,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -386,11 +396,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -399,23 +413,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -429,11 +441,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -442,22 +458,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -471,10 +485,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -482,22 +500,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -509,16 +525,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -526,24 +545,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -556,16 +573,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -573,23 +593,21 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -603,10 +621,14 @@ def build_object_level_worm_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -614,45 +636,41 @@ def build_object_level_worm_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -663,7 +681,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -675,23 +693,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -699,13 +723,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -713,13 +740,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -733,7 +763,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,7 +780,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -754,9 +788,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -780,13 +814,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -795,14 +833,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -820,7 +865,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -829,9 +874,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -854,13 +899,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -869,14 +918,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,7 +946,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -900,7 +956,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -920,11 +976,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -932,12 +993,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,11 +1019,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -981,11 +1049,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -993,12 +1066,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1008,7 +1088,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -1017,9 +1097,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1043,13 +1123,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1058,14 +1142,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,7 +1170,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1088,9 +1179,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1113,13 +1204,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1128,14 +1223,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1149,7 +1251,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1159,9 +1261,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1179,23 +1281,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1207,15 +1318,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,7 +1351,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1243,7 +1362,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1261,18 +1380,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1280,13 +1409,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1303,7 +1440,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1314,7 +1451,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1336,16 +1473,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1353,13 +1500,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1376,7 +1531,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1387,7 +1542,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1412,11 +1567,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1424,13 +1584,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1447,7 +1614,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1457,9 +1624,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1481,20 +1648,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1506,15 +1677,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1531,7 +1709,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1540,9 +1718,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1558,20 +1736,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1583,14 +1765,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1604,21 +1793,26 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - def _object_level_worm_initial( + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1626,12 +1820,19 @@ def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1641,11 +1842,11 @@ def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( + def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1681,19 +1882,26 @@ def begin_object_level_worm( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._object_level_worm_initial( + raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1703,8 +1911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1713,7 +1927,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py index 196432046c2d..b0ad8051848a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,7 +278,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -270,9 +287,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -293,13 +310,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -308,14 +329,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -330,11 +358,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -359,11 +387,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -371,12 +404,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -387,7 +427,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -396,7 +436,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -413,11 +453,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -425,10 +470,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -436,10 +484,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -453,7 +504,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,4 +522,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py index f30d58d02170..4032a1608127 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py index cde710d97c01..c6df72c74666 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py index 99cf9669587f..453b044c1b97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py index 929128c0d855..6e195d2f2d1b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py index 0176d00784ab..6f618628abd3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,10 +227,14 @@ def build_delete_request( include: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -232,25 +242,23 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,16 +269,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -278,23 +289,21 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -307,17 +316,20 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseShareRequest] = None, content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -325,51 +337,47 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -380,7 +388,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -391,24 +399,30 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -416,13 +430,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -430,13 +447,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,7 +470,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +487,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -471,10 +495,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -494,20 +518,24 @@ def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -516,15 +544,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -542,7 +577,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -551,9 +586,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -576,13 +611,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -591,14 +630,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -612,7 +658,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -624,7 +670,7 @@ def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -640,20 +686,26 @@ def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -661,14 +713,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -682,11 +741,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -709,7 +768,7 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -723,11 +782,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -735,14 +799,21 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -752,16 +823,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -785,13 +856,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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[None] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -800,14 +875,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -817,7 +899,7 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace @@ -827,9 +909,9 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -845,22 +927,27 @@ def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -872,15 +959,22 @@ def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,5 +991,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py index 40bbbbd39eb4..744d05c08c79 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, username: str, *, - json: JSONType = None, + json: Optional[_models.LocalUser] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,21 +172,19 @@ def build_delete_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -189,10 +196,14 @@ def build_list_keys_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -200,21 +211,19 @@ def build_list_keys_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -226,10 +235,14 @@ def build_regenerate_password_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -237,45 +250,41 @@ def build_regenerate_password_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LocalUsersOperations(object): - """LocalUsersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`local_users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -283,7 +292,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.LocalUsers"]: + ) -> Iterable[_models.LocalUsers]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -298,11 +307,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUsers"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -310,10 +324,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -321,10 +338,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -338,7 +358,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -352,7 +376,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace def get( @@ -361,7 +385,7 @@ def get( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -379,11 +403,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] request = build_get_request( @@ -391,12 +420,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,7 +447,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace @@ -420,9 +456,9 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: "_models.LocalUser", + properties: _models.LocalUser, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -442,13 +478,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.LocalUser] _json = self._serialize.body(properties, 'LocalUser') @@ -457,14 +497,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -479,11 +526,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -507,11 +554,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -519,12 +571,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -535,7 +594,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace @@ -545,7 +604,7 @@ def list_keys( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserKeys": + ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -563,11 +622,16 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] request = build_list_keys_request( @@ -575,12 +639,19 @@ def list_keys( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -595,7 +666,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace @@ -605,7 +676,7 @@ def regenerate_password( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserRegeneratePasswordResult": + ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -623,11 +694,16 @@ def regenerate_password( :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserRegeneratePasswordResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] request = build_regenerate_password_request( @@ -635,12 +711,19 @@ def regenerate_password( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.regenerate_password.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -655,5 +738,5 @@ def regenerate_password( return deserialized - regenerate_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword'} # type: ignore + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py index 6305a18ad0dd..0096f03f797b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py index cc6cfe89b121..17b3b08a15e8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -309,11 +329,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -321,12 +346,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,7 +373,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -350,9 +382,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -375,13 +407,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -390,14 +426,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,11 +455,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -442,11 +485,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -454,12 +502,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -470,5 +525,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py index 1e11486587f5..af6fa1a3c2f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py index 1a9f1098e929..cade3bce413b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.PrivateEndpointConnection] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py index 64acdd991c88..4e83d0388012 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py index cf48626ee737..1ff65174e7e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,21 +583,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -553,12 +610,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -566,12 +626,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,7 +648,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,4 +665,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py index 1f033a427e00..45a03f592ca0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py index 62404d42c94d..2a602e45c938 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py index f9433cf120c3..30246447746b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -497,32 +513,34 @@ def build_hierarchical_namespace_migration_request_initial( request_type: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -533,31 +551,33 @@ def build_abort_hierarchical_namespace_migration_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -567,39 +587,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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 = "2021-08-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -612,56 +633,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -674,26 +694,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,23 +738,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -731,14 +766,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -754,7 +796,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +804,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -792,35 +834,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -829,13 +883,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -855,23 +908,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -881,7 +946,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -891,7 +956,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -905,31 +970,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,7 +1020,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -951,9 +1028,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -977,13 +1054,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -991,14 +1072,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1012,14 +1100,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1030,29 +1118,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1066,7 +1165,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,14 +1182,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1100,31 +1203,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1138,7 +1252,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1151,7 +1269,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1160,7 +1278,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1171,32 +1289,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1340,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1218,9 +1348,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1239,13 +1369,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1253,14 +1387,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1274,7 +1415,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1282,9 +1423,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1301,13 +1442,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1315,14 +1460,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1336,7 +1488,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1344,9 +1496,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1363,13 +1515,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1377,14 +1533,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1398,32 +1561,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1433,11 +1608,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1466,18 +1641,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1487,8 +1669,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1497,36 +1685,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - def _hierarchical_namespace_migration_initial( + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1536,11 +1735,11 @@ def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( + def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,19 +1772,26 @@ def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._hierarchical_namespace_migration_initial( + raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1595,8 +1801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1605,34 +1817,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - def _abort_hierarchical_namespace_migration_initial( + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1642,11 +1865,11 @@ def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1673,18 +1896,25 @@ def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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] if cont_token is None: - raw_result = self._abort_hierarchical_namespace_migration_initial( + raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1694,8 +1924,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1704,25 +1940,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1730,14 +1969,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1755,7 +2001,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1763,9 +2009,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1790,35 +2036,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1827,13 +2085,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1853,23 +2110,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1879,5 +2148,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py index f58495b99d0d..9316a8e185c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -33,10 +34,14 @@ def build_create_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +49,19 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,10 +73,14 @@ def build_update_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -81,21 +88,19 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -107,10 +112,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -118,21 +127,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -144,10 +151,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -155,21 +166,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -180,55 +189,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -237,7 +246,7 @@ def create( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -256,11 +265,16 @@ def create( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_create_request( @@ -268,12 +282,19 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -287,7 +308,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -297,7 +318,7 @@ def update( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,11 +337,16 @@ def update( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_update_request( @@ -328,12 +354,19 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.update.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -347,7 +380,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -357,7 +390,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -376,11 +409,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -388,12 +426,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -407,11 +452,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -436,11 +481,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -448,12 +498,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -463,7 +520,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -472,7 +529,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -487,11 +544,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -499,10 +561,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -510,10 +575,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -527,7 +595,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -540,4 +612,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py index 65e50a77e308..f5211d91ee90 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-08-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py index 809f901e61ef..0a2a251f1d29 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-08-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_08_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_08_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py index 1072dc103161..317c71b53775 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py index d32248d0f57d..69823f1504a1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials import TokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json index 9db3fcd2abd8..063502cd1df3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json @@ -10,8 +10,8 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py index 340e825f1b00..24ba6339460f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from . import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -74,8 +75,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -94,31 +98,71 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( self, - request, # type: HttpRequest + request: HttpRequest, **kwargs: Any ) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py index 4d0654b74058..aee9e7ff7ef2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.0.0" +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py index 3b85e3279ea7..d763454b9494 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py index c9c41f39b4ae..20ead82eb2f8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClientConfiguration(Configuration): +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for StorageManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class StorageManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -38,6 +41,8 @@ def __init__( **kwargs: Any ) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-09-01") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,7 +50,7 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-09-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py index 9d726dc4b0bf..adfc0b7bacb1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py @@ -7,11 +7,12 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +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 msrest import Deserializer, Serializer from .. import models from ._configuration import StorageManagementClientConfiguration @@ -21,7 +22,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: +class StorageManagementClient: # pylint: disable=too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -77,8 +78,11 @@ class StorageManagementClient: :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2021-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -97,26 +101,66 @@ def __init__( 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.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) - self.storage_accounts = StorageAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deleted_accounts = DeletedAccountsOperations(self._client, self._config, self._serialize, self._deserialize) - self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_policies = ManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_inventory_policies = BlobInventoryPoliciesOperations(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.object_replication_policies = ObjectReplicationPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) - self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) - self.encryption_scopes = EncryptionScopesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) - self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) - self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py index 4c1064ae3825..22f9808d440a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py @@ -27,6 +27,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -49,3 +52,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py index 9b1a8c61fb91..b70331e0b40d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -27,26 +27,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobContainersOperations: - """BlobContainersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -57,7 +55,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListContainerItems"]: + ) -> AsyncIterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -69,12 +67,13 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) @@ -82,11 +81,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -94,13 +98,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -108,13 +115,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +138,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,7 +155,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace_async async def create( @@ -149,9 +163,9 @@ async def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -175,13 +189,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -190,14 +208,21 @@ async def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -215,7 +240,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -224,9 +249,9 @@ async def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -249,13 +274,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -264,14 +293,21 @@ async def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -285,7 +321,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -295,7 +331,7 @@ async def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -315,11 +351,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -327,12 +368,19 @@ async def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,11 +394,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -376,11 +424,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -388,12 +441,19 @@ async def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -403,7 +463,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async @@ -412,9 +472,9 @@ async def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -438,13 +498,17 @@ async def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -453,14 +517,21 @@ async def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -474,7 +545,7 @@ async def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace_async @@ -483,9 +554,9 @@ async def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -508,13 +579,17 @@ async def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -523,14 +598,21 @@ async def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +626,7 @@ async def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace_async @@ -554,9 +636,9 @@ async def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -574,23 +656,32 @@ async def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -602,15 +693,23 @@ async def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -627,7 +726,7 @@ async def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -638,7 +737,7 @@ async def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -656,18 +755,28 @@ async def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -675,13 +784,21 @@ async def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -698,7 +815,7 @@ async def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -709,7 +826,7 @@ async def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -731,16 +848,26 @@ async def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -748,13 +875,21 @@ async def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -771,7 +906,7 @@ async def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async @@ -782,7 +917,7 @@ async def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -807,11 +942,16 @@ async def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -819,13 +959,20 @@ async def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -842,7 +989,7 @@ async def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace_async @@ -852,9 +999,9 @@ async def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -876,20 +1023,24 @@ async def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -901,15 +1052,22 @@ async def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -926,7 +1084,7 @@ async def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace_async @@ -935,9 +1093,9 @@ async def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -953,20 +1111,24 @@ async def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -978,14 +1140,21 @@ async def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -999,21 +1168,26 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - async def _object_level_worm_initial( + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1021,12 +1195,19 @@ async def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1036,11 +1217,11 @@ async def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( + async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1076,19 +1257,26 @@ async def begin_object_level_worm( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = await self._object_level_worm_initial( + raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1098,8 +1286,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1108,7 +1302,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py index 5de50bde8972..c7bec22d883e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobInventoryPoliciesOperations: - """BlobInventoryPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +51,7 @@ async def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -72,11 +70,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -84,12 +87,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,7 +113,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async @@ -112,9 +122,9 @@ async def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -135,13 +145,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -150,14 +164,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,11 +192,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -200,11 +221,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -212,12 +238,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -227,7 +260,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -236,7 +269,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListBlobInventoryPolicy"]: + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -253,11 +286,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -265,10 +303,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -276,10 +317,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -293,7 +337,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,4 +355,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py index 9a5e667b4584..f8ff422a9431 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class BlobServicesOperations: - """BlobServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.BlobServiceItems"]: + ) -> AsyncIterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -121,16 +134,16 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace_async async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -144,18 +157,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -163,14 +185,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +214,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async @@ -193,7 +223,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -204,28 +234,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -239,5 +287,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py index 16166ba91e75..ff5dfd1bdb8e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,32 +25,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class DeletedAccountsOperations: - """DeletedAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.DeletedAccountListResult"]: + ) -> AsyncIterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +58,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +105,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -110,7 +123,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async async def get( @@ -118,7 +131,7 @@ async def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -130,23 +143,35 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,5 +186,5 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py index aa76277f7cce..52ff5528677c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class EncryptionScopesOperations: - """EncryptionScopesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def put( @@ -52,9 +50,9 @@ async def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -78,13 +76,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -93,14 +95,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -119,7 +128,7 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -128,9 +137,9 @@ async def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -153,13 +162,17 @@ async def patch( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -168,14 +181,21 @@ async def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,7 +210,7 @@ async def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async @@ -200,7 +220,7 @@ async def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -220,11 +240,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -232,12 +257,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -252,7 +284,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -261,7 +293,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.EncryptionScopeListResult"]: + ) -> AsyncIterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -278,11 +310,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -290,10 +327,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -301,10 +341,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -318,7 +361,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -331,4 +378,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py index 9775d73a13ea..762f31d452af 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileServicesOperations: - """FileServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py index 021e29f74d93..5b5c474ee5c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class FileSharesOperations: - """FileSharesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -55,7 +53,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.FileShareItems"]: + ) -> AsyncIterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -66,13 +64,14 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) @@ -80,11 +79,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -92,13 +96,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -106,13 +113,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -126,7 +136,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -139,7 +153,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace_async async def create( @@ -147,10 +161,10 @@ async def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -170,20 +184,24 @@ async def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -192,15 +210,22 @@ async def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -218,7 +243,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -227,9 +252,9 @@ async def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -252,13 +277,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -267,14 +296,21 @@ async def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -288,7 +324,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async @@ -300,7 +336,7 @@ async def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -316,20 +352,26 @@ async def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -337,14 +379,21 @@ async def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,11 +407,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -385,7 +434,7 @@ async def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -399,11 +448,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -411,14 +465,21 @@ async def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -428,16 +489,16 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async - async def restore( + async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -461,13 +522,17 @@ async def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -476,14 +541,21 @@ async def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -493,7 +565,7 @@ async def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace_async @@ -503,9 +575,9 @@ async def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -521,22 +593,27 @@ async def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -548,15 +625,22 @@ async def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -573,5 +657,5 @@ async def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py index e384431d87e2..a31b89af5d59 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class LocalUsersOperations: - """LocalUsersOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`local_users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.LocalUsers"]: + ) -> AsyncIterable[_models.LocalUsers]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,11 +66,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUsers"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -80,10 +83,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -91,10 +97,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -108,7 +117,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: "_models.LocalUser", + properties: _models.LocalUser, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LocalUser] _json = self._serialize.body(properties, 'LocalUser') @@ -227,14 +256,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,7 +353,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async @@ -315,7 +363,7 @@ async def list_keys( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserKeys": + ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -333,11 +381,16 @@ async def list_keys( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] request = build_list_keys_request( @@ -345,12 +398,19 @@ async def list_keys( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -365,7 +425,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace_async @@ -375,7 +435,7 @@ async def regenerate_password( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserRegeneratePasswordResult": + ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -393,11 +453,16 @@ async def regenerate_password( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserRegeneratePasswordResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] request = build_regenerate_password_request( @@ -405,12 +470,19 @@ async def regenerate_password( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.regenerate_password.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -425,5 +497,5 @@ async def regenerate_password( return deserialized - regenerate_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword'} # type: ignore + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py index 34eca843bacc..08eeb6fe367c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ManagementPoliciesOperations: - """ManagementPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -51,7 +49,7 @@ async def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -70,11 +68,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -82,12 +85,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,7 +111,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async @@ -110,9 +120,9 @@ async def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -133,13 +143,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -148,14 +162,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,11 +190,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -198,11 +219,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -210,12 +236,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,5 +258,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py index c39ca0a3f9b5..42c4e4d83662 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ObjectReplicationPoliciesOperations: - """ObjectReplicationPoliciesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ObjectReplicationPolicies"]: + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,7 +136,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( @@ -132,7 +145,7 @@ async def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -152,11 +165,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -164,12 +182,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -184,7 +209,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async @@ -193,9 +218,9 @@ async def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -218,13 +243,17 @@ async def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -233,14 +262,21 @@ async def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,11 +291,11 @@ async def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -285,11 +321,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -297,12 +338,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -313,5 +361,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py index 658ad196ca6d..fba333183c00 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + ) -> AsyncIterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -59,27 +56,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +101,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -106,4 +118,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py index ec3e8159a4be..246294577182 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateEndpointConnectionsOperations: - """PrivateEndpointConnectionsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -52,7 +50,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -69,11 +67,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -81,10 +84,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -92,10 +98,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +118,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -122,7 +135,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( @@ -131,7 +144,7 @@ async def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -149,11 +162,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -161,12 +179,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +206,7 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async @@ -190,9 +215,9 @@ async def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -212,13 +237,17 @@ async def put( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -227,14 +256,21 @@ async def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -249,11 +285,11 @@ async def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -277,11 +313,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -289,12 +330,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -305,5 +353,5 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py index 8d78a668ab56..41afa2e996d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class PrivateLinkResourcesOperations: - """PrivateLinkResourcesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list_by_storage_account( @@ -50,7 +48,7 @@ async def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,5 +105,5 @@ async def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py index c3a1030a57f6..632a2e264d15 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueOperations: - """QueueOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -76,13 +74,17 @@ async def create( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -91,14 +93,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -112,7 +121,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -121,9 +130,9 @@ async def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -145,13 +154,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -160,14 +173,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,7 +201,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async @@ -191,7 +211,7 @@ async def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -211,11 +231,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -223,12 +248,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -242,11 +274,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -272,11 +304,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -284,12 +321,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -299,7 +343,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ListQueueResource"]: + ) -> AsyncIterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -321,10 +365,10 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) @@ -332,11 +376,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -344,12 +393,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -357,12 +409,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -376,7 +431,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -389,4 +448,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py index 3d901a4a5605..6067116acf15 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QueueServicesOperations: - """QueueServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py index ef2c47bd4d52..edec00dbecd8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,32 +24,30 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class SkusOperations: - """SkusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageSkuListResult"]: + ) -> AsyncIterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -60,29 +57,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -96,7 +104,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,4 +121,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py index d8659a0e69de..bec093e53520 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -17,6 +16,7 @@ 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 @@ -26,34 +26,32 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class StorageAccountsOperations: - """StorageAccountsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -66,26 +64,37 @@ async def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,23 +108,27 @@ async def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -123,14 +136,21 @@ async def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -146,7 +166,7 @@ async def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -154,9 +174,9 @@ async def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.StorageAccount"]: + ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -185,35 +205,47 @@ async def begin_create( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount] + 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_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + 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( @@ -222,13 +254,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -248,23 +279,35 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -274,7 +317,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -284,7 +327,7 @@ async def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -298,31 +341,43 @@ async def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -336,7 +391,7 @@ async def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async @@ -344,9 +399,9 @@ async def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -370,13 +425,17 @@ async def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -384,14 +443,21 @@ async def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -405,14 +471,14 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -423,29 +489,40 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -459,7 +536,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -472,14 +553,14 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.StorageAccountListResult"]: + ) -> AsyncIterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -493,31 +574,42 @@ def list_by_resource_group( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -531,7 +623,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -544,7 +640,7 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( @@ -553,7 +649,7 @@ async def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -564,32 +660,44 @@ async def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -603,7 +711,7 @@ async def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace_async @@ -611,9 +719,9 @@ async def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -632,13 +740,17 @@ async def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -646,14 +758,21 @@ async def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -667,7 +786,7 @@ async def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace_async @@ -675,9 +794,9 @@ async def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -694,13 +813,17 @@ async def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -708,14 +831,21 @@ async def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -729,7 +859,7 @@ async def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace_async @@ -737,9 +867,9 @@ async def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -756,13 +886,17 @@ async def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -770,14 +904,21 @@ async def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -791,32 +932,44 @@ async def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - async def _failover_initial( + async def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -826,11 +979,11 @@ async def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( + async def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -859,18 +1012,25 @@ async def begin_failover( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = await self._failover_initial( + raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -880,8 +1040,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -890,36 +1056,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - async def _hierarchical_namespace_migration_initial( + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -929,11 +1106,11 @@ async def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( + async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -966,19 +1143,26 @@ async def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = await self._hierarchical_namespace_migration_initial( + raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -988,8 +1172,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -998,34 +1188,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - async def _abort_hierarchical_namespace_migration_initial( + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1035,11 +1236,11 @@ async def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1066,18 +1267,25 @@ async def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = await self._abort_hierarchical_namespace_migration_initial( + raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1087,8 +1295,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1097,25 +1311,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1123,14 +1340,21 @@ async def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1148,7 +1372,7 @@ async def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async @@ -1156,9 +1380,9 @@ async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> AsyncLROPoller["_models.BlobRestoreStatus"]: + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1184,35 +1408,47 @@ async def begin_restore_blob_ranges( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -1221,13 +1457,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async - async def revoke_user_delegation_keys( + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1247,23 +1482,35 @@ async def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1273,5 +1520,5 @@ async def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py index 21172a8c9337..6ecab78e6781 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,6 +15,7 @@ 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 @@ -25,26 +25,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableOperations: - """TableOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def create( @@ -52,9 +50,9 @@ async def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional["_models.Table"] = None, + parameters: Optional[_models.Table] = None, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -68,20 +66,24 @@ async def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. :type table_name: str - :param parameters: The parameters to provide to create a table. + :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.Table] if parameters is not None: _json = self._serialize.body(parameters, 'Table') @@ -93,14 +95,21 @@ async def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,7 +123,7 @@ async def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -123,9 +132,9 @@ async def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional["_models.Table"] = None, + parameters: Optional[_models.Table] = None, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -139,20 +148,24 @@ async def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. :type table_name: str - :param parameters: The parameters to provide to create a table. + :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.Table] if parameters is not None: _json = self._serialize.body(parameters, 'Table') @@ -164,14 +177,21 @@ async def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -185,7 +205,7 @@ async def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async @@ -195,7 +215,7 @@ async def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -214,11 +234,16 @@ async def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -226,12 +251,19 @@ async def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -245,11 +277,11 @@ async def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -274,11 +306,16 @@ async def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -286,12 +323,19 @@ async def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -301,7 +345,7 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -310,7 +354,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListTableResource"]: + ) -> AsyncIterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -326,11 +370,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -338,10 +387,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -349,10 +401,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -366,7 +421,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -379,4 +438,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py index 64656f0f29cf..96add7ed72c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,15 +6,14 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -23,26 +23,24 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class TableServicesOperations: - """TableServicesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def list( @@ -50,7 +48,7 @@ async def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -65,23 +63,35 @@ async def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -95,7 +105,7 @@ async def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace_async @@ -103,9 +113,9 @@ async def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -119,18 +129,27 @@ async def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -138,14 +157,22 @@ async def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,7 +186,7 @@ async def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async @@ -168,7 +195,7 @@ async def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -179,28 +206,46 @@ async def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -214,5 +259,5 @@ async def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py index bf64b18fce91..fc903859e18b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -15,7 +14,7 @@ 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 @@ -25,33 +24,31 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class UsagesOperations: - """UsagesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.aio.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> AsyncIterable["_models.UsageListResult"]: + ) -> AsyncIterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -63,31 +60,42 @@ def list_by_location( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -101,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,4 +126,4 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py index bf2bacae2c76..8d3930cd6c2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py @@ -222,7 +222,9 @@ StorageAccountExpand, UsageUnit, ) - +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__ = [ 'AccessPolicy', 'AccountImmutabilityPolicyProperties', @@ -437,3 +439,5 @@ 'StorageAccountExpand', 'UsageUnit', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py index 9231ba171114..0a4ce2403020 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._storage_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AccessPolicy(msrest.serialization.Model): @@ -65,7 +67,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and @@ -89,7 +91,7 @@ def __init__( self, *, immutability_period_since_creation_in_days: Optional[int] = None, - state: Optional[Union[str, "AccountImmutabilityPolicyState"]] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, allow_protected_append_writes: Optional[bool] = None, **kwargs ): @@ -102,7 +104,7 @@ def __init__( and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state - can transition to a Locked state which cannot be reverted. Possible values include: "Unlocked", + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", "Locked", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and @@ -123,22 +125,22 @@ class AccountSasParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", "t", "f". + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :vartype services: str or ~azure.mgmt.storage.v2021_09_01.models.Services :ivar resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Possible values include: "s", "c", "o". + Known values are: "s", "c", "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResourceTypes :ivar permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -170,35 +172,34 @@ class AccountSasParameters(msrest.serialization.Model): def __init__( self, *, - services: Union[str, "Services"], - resource_types: Union[str, "SignedResourceTypes"], - permissions: Union[str, "Permissions"], + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], shared_access_expiry_time: datetime.datetime, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, key_to_sign: Optional[str] = None, **kwargs ): """ :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Possible values include: "b", "q", - "t", "f". + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". :paramtype services: str or ~azure.mgmt.storage.v2021_09_01.models.Services :keyword resource_types: Required. The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Possible values include: "s", "c", "o". + entities, and files. Known values are: "s", "c", "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResourceTypes :keyword permissions: Required. The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Possible values include: "r", "d", "w", "l", "a", "c", "u", "p". + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -239,8 +240,8 @@ class ActiveDirectoryProperties(msrest.serialization.Model): :vartype azure_storage_sid: str :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :vartype sam_account_name: str - :ivar account_type: Specifies the Active Directory account type for Azure Storage. Possible - values include: "User", "Computer". + :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values + are: "User", "Computer". :vartype account_type: str or ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryPropertiesAccountType """ @@ -275,7 +276,7 @@ def __init__( domain_sid: str, azure_storage_sid: str, sam_account_name: Optional[str] = None, - account_type: Optional[Union[str, "ActiveDirectoryPropertiesAccountType"]] = None, + account_type: Optional[Union[str, "_models.ActiveDirectoryPropertiesAccountType"]] = None, **kwargs ): """ @@ -295,8 +296,8 @@ def __init__( :paramtype azure_storage_sid: str :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :paramtype sam_account_name: str - :keyword account_type: Specifies the Active Directory account type for Azure Storage. Possible - values include: "User", "Computer". + :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known + values are: "User", "Computer". :paramtype account_type: str or ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryPropertiesAccountType """ @@ -396,15 +397,15 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :ivar directory_service_options: Required. Indicates the directory service used. Known values + are: "None", "AADDS", "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_09_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. :vartype active_directory_properties: ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or @@ -424,21 +425,21 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): def __init__( self, *, - directory_service_options: Union[str, "DirectoryServiceOptions"], - active_directory_properties: Optional["ActiveDirectoryProperties"] = None, - default_share_permission: Optional[Union[str, "DefaultSharePermission"]] = None, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Possible - values include: "None", "AADDS", "AD". + :keyword directory_service_options: Required. Indicates the directory service used. Known + values are: "None", "AADDS", "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_09_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos - authentication if RBAC role is not assigned. Possible values include: "None", + authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or @@ -480,18 +481,17 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -570,9 +570,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -585,7 +585,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -662,7 +662,7 @@ class BlobInventoryPolicy(Resource): def __init__( self, *, - policy: Optional["BlobInventoryPolicySchema"] = None, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs ): """ @@ -684,14 +684,13 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyFilter :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_09_01.models.Format :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Possible values include: "Daily", "Weekly". + formation. Known values are: "Daily", "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_09_01.models.Schedule :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_09_01.models.ObjectType :ivar schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -733,25 +732,24 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - format: Union[str, "Format"], - schedule: Union[str, "Schedule"], - object_type: Union[str, "ObjectType"], + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], schema_fields: List[str], - filters: Optional["BlobInventoryPolicyFilter"] = None, + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, **kwargs ): """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyFilter :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Possible values include: "Csv", "Parquet". + files. Known values are: "Csv", "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_09_01.models.Format :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Possible values include: "Daily", "Weekly". + inventory formation. Known values are: "Daily", "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_09_01.models.Schedule :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Possible values include: "Blob", - "Container". + inventory created either at the blob or container level. Known values are: "Blob", "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_09_01.models.ObjectType :keyword schema_fields: Required. This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is @@ -905,7 +903,7 @@ def __init__( enabled: bool, name: str, destination: str, - definition: "BlobInventoryPolicyDefinition", + definition: "_models.BlobInventoryPolicyDefinition", **kwargs ): """ @@ -939,7 +937,7 @@ class BlobInventoryPolicySchema(msrest.serialization.Model): :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required destination container name must be specified at the rule level 'policy.rule.destination'. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Possible values include: "Inventory". + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.InventoryRuleType :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -964,14 +962,14 @@ def __init__( self, *, enabled: bool, - type: Union[str, "InventoryRuleType"], - rules: List["BlobInventoryPolicyRule"], + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], **kwargs ): """ :keyword enabled: Required. Policy is enabled if set to true. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Possible values include: "Inventory". + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.InventoryRuleType :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied when it is enabled. @@ -1009,7 +1007,7 @@ def __init__( self, *, time_to_restore: datetime.datetime, - blob_ranges: List["BlobRestoreRange"], + blob_ranges: List["_models.BlobRestoreRange"], **kwargs ): """ @@ -1069,8 +1067,8 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed - successfully. - Failed: Indicates that blob restore is failed. Possible values include: - "InProgress", "Complete", "Failed". + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1202,15 +1200,15 @@ class BlobServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, default_service_version: Optional[str] = None, - delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, is_versioning_enabled: Optional[bool] = None, automatic_snapshot_policy_enabled: Optional[bool] = None, - change_feed: Optional["ChangeFeed"] = None, - restore_policy: Optional["RestorePolicyProperties"] = None, - container_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - last_access_time_tracking_policy: Optional["LastAccessTimeTrackingPolicy"] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, **kwargs ): """ @@ -1306,7 +1304,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Possible values include: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_09_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1366,7 +1364,7 @@ def __init__( code: Optional[str] = None, message: Optional[str] = None, target: Optional[str] = None, - details: Optional[List["CloudErrorBody"]] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, **kwargs ): """ @@ -1432,7 +1430,7 @@ def __init__( self, *, allowed_origins: List[str], - allowed_methods: List[Union[str, "CorsRuleAllowedMethodsItem"]], + allowed_methods: List[Union[str, "_models.CorsRuleAllowedMethodsItem"]], max_age_in_seconds: int, exposed_headers: List[str], allowed_headers: List[str], @@ -1479,7 +1477,7 @@ class CorsRules(msrest.serialization.Model): def __init__( self, *, - cors_rules: Optional[List["CorsRule"]] = None, + cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs ): """ @@ -1909,7 +1907,7 @@ class Encryption(msrest.serialization.Model): :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_09_01.models.EncryptionServices :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :vartype key_source: str or ~azure.mgmt.storage.v2021_09_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service @@ -1936,18 +1934,18 @@ class Encryption(msrest.serialization.Model): def __init__( self, *, - key_source: Union[str, "KeySource"] = "Microsoft.Storage", - services: Optional["EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + services: Optional["_models.EncryptionServices"] = None, require_infrastructure_encryption: Optional[bool] = None, - key_vault_properties: Optional["KeyVaultProperties"] = None, - encryption_identity: Optional["EncryptionIdentity"] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_09_01.models.EncryptionServices :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Possible values include: + (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". :paramtype key_source: str or ~azure.mgmt.storage.v2021_09_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service @@ -2018,11 +2016,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Possible values include: "Enabled", "Disabled". + Disabled. Known values are: "Enabled", "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -2061,19 +2059,19 @@ class EncryptionScope(Resource): def __init__( self, *, - source: Optional[Union[str, "EncryptionScopeSource"]] = None, - state: Optional[Union[str, "EncryptionScopeState"]] = None, - key_vault_properties: Optional["EncryptionScopeKeyVaultProperties"] = None, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, require_infrastructure_encryption: Optional[bool] = None, **kwargs ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Possible values include: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Possible values include: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled", "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2183,7 +2181,7 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Possible values include: "Service", "Account". + default service key is used. Known values are: "Service", "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_09_01.models.KeyType """ @@ -2201,7 +2199,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - key_type: Optional[Union[str, "KeyType"]] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ @@ -2210,7 +2208,7 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Possible values include: "Service", "Account". + that a default service key is used. Known values are: "Service", "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_09_01.models.KeyType """ super(EncryptionService, self).__init__(**kwargs) @@ -2242,10 +2240,10 @@ class EncryptionServices(msrest.serialization.Model): def __init__( self, *, - blob: Optional["EncryptionService"] = None, - file: Optional["EncryptionService"] = None, - table: Optional["EncryptionService"] = None, - queue: Optional["EncryptionService"] = None, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, **kwargs ): """ @@ -2313,8 +2311,8 @@ class Endpoints(msrest.serialization.Model): def __init__( self, *, - microsoft_endpoints: Optional["StorageAccountMicrosoftEndpoints"] = None, - internet_endpoints: Optional["StorageAccountInternetEndpoints"] = None, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, **kwargs ): """ @@ -2350,7 +2348,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorResponseBody"] = None, + error: Optional["_models.ErrorResponseBody"] = None, **kwargs ): """ @@ -2402,7 +2400,7 @@ class ExtendedLocation(msrest.serialization.Model): :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Possible values include: "EdgeZone". + :ivar type: The type of the extended location. Known values are: "EdgeZone". :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocationTypes """ @@ -2415,13 +2413,13 @@ def __init__( self, *, name: Optional[str] = None, - type: Optional[Union[str, "ExtendedLocationTypes"]] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, **kwargs ): """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Possible values include: "EdgeZone". + :keyword type: The type of the extended location. Known values are: "EdgeZone". :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocationTypes """ super(ExtendedLocation, self).__init__(**kwargs) @@ -2502,9 +2500,9 @@ class FileServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, - share_delete_retention_policy: Optional["DeleteRetentionPolicy"] = None, - protocol_settings: Optional["ProtocolSettings"] = None, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, **kwargs ): """ @@ -2548,10 +2546,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2562,8 +2560,8 @@ class FileShare(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2572,14 +2570,13 @@ class FileShare(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2638,10 +2635,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2651,14 +2648,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2707,10 +2704,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Possible values include: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB", "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols - :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2721,8 +2718,8 @@ class FileShareItem(AzureEntityResource): :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2731,14 +2728,13 @@ class FileShareItem(AzureEntityResource): :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus - :ivar lease_state: Lease state of the share. Possible values include: "Available", "Leased", + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Possible values include: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2797,10 +2793,10 @@ def __init__( *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, - enabled_protocols: Optional[Union[str, "EnabledProtocols"]] = None, - root_squash: Optional[Union[str, "RootSquashType"]] = None, - access_tier: Optional[Union[str, "ShareAccessTier"]] = None, - signed_identifiers: Optional[List["SignedIdentifier"]] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, **kwargs ): """ @@ -2810,14 +2806,14 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Possible values include: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB", "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols - :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Possible - values include: "NoRootSquash", "RootSquash", "AllSquash". + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between - TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Possible - values include: "TransactionOptimized", "Hot", "Cool", "Premium". + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2885,8 +2881,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Possible values include: "Live", "Bootstrap", - "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2933,7 +2928,7 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of @@ -2959,12 +2954,12 @@ class Identity(msrest.serialization.Model): def __init__( self, *, - type: Union[str, "IdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. The identity type. Possible values include: "None", "SystemAssigned", + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", "UserAssigned", "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set @@ -2999,7 +2994,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3081,7 +3076,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Possible values include: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked", "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3172,7 +3167,7 @@ def __init__( self, *, enabled: Optional[bool] = None, - immutability_policy: Optional["AccountImmutabilityPolicyProperties"] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, **kwargs ): """ @@ -3203,7 +3198,7 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Possible values include: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress", "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_09_01.models.MigrationState """ @@ -3409,7 +3404,7 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): :ivar enable: Required. When set to true last access time based tracking is enabled. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Possible values include: "AccessTimeTracking". + read only. Known values are: "AccessTimeTracking". :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3435,7 +3430,7 @@ def __init__( self, *, enable: bool, - name: Optional[Union[str, "Name"]] = None, + name: Optional[Union[str, "_models.Name"]] = None, tracking_granularity_in_days: Optional[int] = None, blob_type: Optional[List[str]] = None, **kwargs @@ -3444,7 +3439,7 @@ def __init__( :keyword enable: Required. When set to true last access time based tracking is enabled. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Possible values include: "AccessTimeTracking". + currently read only. Known values are: "AccessTimeTracking". :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3466,8 +3461,8 @@ class LeaseContainerRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3497,7 +3492,7 @@ class LeaseContainerRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseContainerRequestAction"], + action: Union[str, "_models.LeaseContainerRequestAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3506,7 +3501,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3567,8 +3562,8 @@ class LeaseShareRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3598,7 +3593,7 @@ class LeaseShareRequest(msrest.serialization.Model): def __init__( self, *, - action: Union[str, "LeaseShareAction"], + action: Union[str, "_models.LeaseShareAction"], lease_id: Optional[str] = None, break_period: Optional[int] = None, lease_duration: Optional[int] = None, @@ -3607,7 +3602,7 @@ def __init__( ): """ :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Possible values include: "Acquire", "Renew", "Change", "Release", "Break". + Known values are: "Acquire", "Renew", "Change", "Release", "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3747,8 +3742,8 @@ class LegalHoldProperties(msrest.serialization.Model): def __init__( self, *, - tags: Optional[List["TagProperty"]] = None, - protected_append_writes_history: Optional["ProtectedAppendWritesHistory"] = None, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, **kwargs ): """ @@ -3848,18 +3843,17 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Possible values include: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Possible values include: "Locked", - "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus - :ivar lease_state: Lease state of the container. Possible values include: "Available", - "Leased", "Expired", "Breaking", "Broken". + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Possible values include: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite", "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3938,9 +3932,9 @@ def __init__( *, default_encryption_scope: Optional[str] = None, deny_encryption_scope_override: Optional[bool] = None, - public_access: Optional[Union[str, "PublicAccess"]] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, metadata: Optional[Dict[str, str]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageWithVersioning"] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, enable_nfs_v3_root_squash: Optional[bool] = None, enable_nfs_v3_all_squash: Optional[bool] = None, **kwargs @@ -3953,7 +3947,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Possible values include: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -4270,9 +4264,9 @@ class LocalUser(Resource): def __init__( self, *, - permission_scopes: Optional[List["PermissionScope"]] = None, + permission_scopes: Optional[List["_models.PermissionScope"]] = None, home_directory: Optional[str] = None, - ssh_authorized_keys: Optional[List["SshPublicKey"]] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, has_shared_key: Optional[bool] = None, has_ssh_key: Optional[bool] = None, has_ssh_password: Optional[bool] = None, @@ -4329,7 +4323,7 @@ class LocalUserKeys(msrest.serialization.Model): def __init__( self, *, - ssh_authorized_keys: Optional[List["SshPublicKey"]] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs ): """ @@ -4383,7 +4377,7 @@ class LocalUsers(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["LocalUser"]] = None, + value: Optional[List["_models.LocalUser"]] = None, **kwargs ): """ @@ -4432,7 +4426,7 @@ class ManagementPolicy(Resource): def __init__( self, *, - policy: Optional["ManagementPolicySchema"] = None, + policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs ): """ @@ -4465,9 +4459,9 @@ class ManagementPolicyAction(msrest.serialization.Model): def __init__( self, *, - base_blob: Optional["ManagementPolicyBaseBlob"] = None, - snapshot: Optional["ManagementPolicySnapShot"] = None, - version: Optional["ManagementPolicyVersion"] = None, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, **kwargs ): """ @@ -4510,9 +4504,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterModification"] = None, - tier_to_archive: Optional["DateAfterModification"] = None, - delete: Optional["DateAfterModification"] = None, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, enable_auto_tier_to_hot_from_cool: Optional[bool] = None, **kwargs ): @@ -4560,8 +4554,8 @@ class ManagementPolicyDefinition(msrest.serialization.Model): def __init__( self, *, - actions: "ManagementPolicyAction", - filters: Optional["ManagementPolicyFilter"] = None, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, **kwargs ): """ @@ -4605,7 +4599,7 @@ def __init__( *, blob_types: List[str], prefix_match: Optional[List[str]] = None, - blob_index_match: Optional[List["TagFilter"]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, **kwargs ): """ @@ -4634,7 +4628,7 @@ class ManagementPolicyRule(msrest.serialization.Model): :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.RuleType :ivar definition: Required. An object that defines the Lifecycle rule. :vartype definition: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyDefinition @@ -4657,8 +4651,8 @@ def __init__( self, *, name: str, - type: Union[str, "RuleType"], - definition: "ManagementPolicyDefinition", + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", enabled: Optional[bool] = None, **kwargs ): @@ -4668,7 +4662,7 @@ def __init__( :keyword name: Required. A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Possible values include: "Lifecycle". + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.RuleType :keyword definition: Required. An object that defines the Lifecycle rule. :paramtype definition: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyDefinition @@ -4701,7 +4695,7 @@ class ManagementPolicySchema(msrest.serialization.Model): def __init__( self, *, - rules: List["ManagementPolicyRule"], + rules: List["_models.ManagementPolicyRule"], **kwargs ): """ @@ -4735,9 +4729,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4778,9 +4772,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): def __init__( self, *, - tier_to_cool: Optional["DateAfterCreation"] = None, - tier_to_archive: Optional["DateAfterCreation"] = None, - delete: Optional["DateAfterCreation"] = None, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, **kwargs ): """ @@ -4841,7 +4835,7 @@ def __init__( display_name: Optional[str] = None, display_description: Optional[str] = None, unit: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[bool] = None, category: Optional[str] = None, @@ -4912,8 +4906,8 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Possible values include: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_09_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_09_01.models.ResourceAccessRule] @@ -4922,7 +4916,7 @@ class NetworkRuleSet(msrest.serialization.Model): :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_09_01.models.IPRule] :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :vartype default_action: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultAction """ @@ -4941,18 +4935,18 @@ class NetworkRuleSet(msrest.serialization.Model): def __init__( self, *, - default_action: Union[str, "DefaultAction"] = "Allow", - bypass: Optional[Union[str, "Bypass"]] = "AzureServices", - resource_access_rules: Optional[List["ResourceAccessRule"]] = None, - virtual_network_rules: Optional[List["VirtualNetworkRule"]] = None, - ip_rules: Optional[List["IPRule"]] = None, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs ): """ :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, - Metrics"), or None to bypass none of those traffics. Possible values include: "None", - "Logging", "Metrics", "AzureServices". Default value: "AzureServices". + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_09_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4963,7 +4957,7 @@ def __init__( :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_09_01.models.IPRule] :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Possible values include: "Allow", "Deny". Default value: "Allow". + rules match. Known values are: "Allow", "Deny". Default value: "Allow". :paramtype default_action: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultAction """ super(NetworkRuleSet, self).__init__(**kwargs) @@ -4988,7 +4982,7 @@ class ObjectReplicationPolicies(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ObjectReplicationPolicy"]] = None, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs ): """ @@ -5050,7 +5044,7 @@ def __init__( *, source_account: Optional[str] = None, destination_account: Optional[str] = None, - rules: Optional[List["ObjectReplicationPolicyRule"]] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, **kwargs ): """ @@ -5141,7 +5135,7 @@ def __init__( source_container: str, destination_container: str, rule_id: Optional[str] = None, - filters: Optional["ObjectReplicationPolicyFilter"] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, **kwargs ): """ @@ -5186,9 +5180,9 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - service_specification: Optional["ServiceSpecification"] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs ): """ @@ -5268,7 +5262,7 @@ class OperationListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.Operation"]] = None, **kwargs ): """ @@ -5377,7 +5371,7 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Possible values include: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionProvisioningState """ @@ -5401,8 +5395,8 @@ class PrivateEndpointConnection(Resource): def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -5433,7 +5427,7 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs ): """ @@ -5512,7 +5506,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["PrivateLinkResource"]] = None, + value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs ): """ @@ -5527,7 +5521,7 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5546,14 +5540,14 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): def __init__( self, *, - status: Optional[Union[str, "PrivateEndpointServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, description: Optional[str] = None, action_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5621,7 +5615,7 @@ class ProtocolSettings(msrest.serialization.Model): def __init__( self, *, - smb: Optional["SmbSetting"] = None, + smb: Optional["_models.SmbSetting"] = None, **kwargs ): """ @@ -5667,7 +5661,7 @@ class QueueServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -5778,7 +5772,7 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_09_01.models.ReasonCode """ @@ -5796,14 +5790,14 @@ class Restriction(msrest.serialization.Model): def __init__( self, *, - reason_code: Optional[Union[str, "ReasonCode"]] = None, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs ): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Possible values include: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_09_01.models.ReasonCode """ super(Restriction, self).__init__(**kwargs) @@ -5816,7 +5810,7 @@ class RoutingPreference(msrest.serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_09_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5835,14 +5829,14 @@ class RoutingPreference(msrest.serialization.Model): def __init__( self, *, - routing_choice: Optional[Union[str, "RoutingChoice"]] = None, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, publish_microsoft_endpoints: Optional[bool] = None, publish_internet_endpoints: Optional[bool] = None, **kwargs ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Possible values include: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting", "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_09_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5864,8 +5858,8 @@ class SasPolicy(msrest.serialization.Model): :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Possible values - include: "Log". Default value: "Log". + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :vartype expiration_action: str or ~azure.mgmt.storage.v2021_09_01.models.ExpirationAction """ @@ -5883,14 +5877,14 @@ def __init__( self, *, sas_expiration_period: str, - expiration_action: Union[str, "ExpirationAction"] = "Log", + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Possible - values include: "Log". Default value: "Log". + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_09_01.models.ExpirationAction """ super(SasPolicy, self).__init__(**kwargs) @@ -5906,17 +5900,17 @@ class ServiceSasParameters(msrest.serialization.Model): :ivar canonicalized_resource: Required. The canonical path to the signed resource. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :vartype resource: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str - :ivar protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5977,10 +5971,10 @@ def __init__( self, *, canonicalized_resource: str, - resource: Optional[Union[str, "SignedResource"]] = None, - permissions: Optional[Union[str, "Permissions"]] = None, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, ip_address_or_range: Optional[str] = None, - protocols: Optional[Union[str, "HttpProtocol"]] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, shared_access_start_time: Optional[datetime.datetime] = None, shared_access_expiry_time: Optional[datetime.datetime] = None, identifier: Optional[str] = None, @@ -6000,18 +5994,17 @@ def __init__( :keyword canonicalized_resource: Required. The canonical path to the signed resource. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Possible values include: "b", "c", "f", - "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read - (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Possible - values include: "r", "d", "w", "l", "a", "c", "u", "p". + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str - :keyword protocols: The protocol permitted for a request made with the account SAS. Possible - values include: "https,http", "https". + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -6078,7 +6071,7 @@ class ServiceSpecification(msrest.serialization.Model): def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs ): """ @@ -6108,7 +6101,7 @@ def __init__( self, *, id: Optional[str] = None, - access_policy: Optional["AccessPolicy"] = None, + access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): """ @@ -6130,11 +6123,11 @@ class Sku(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_09_01.models.SkuTier """ @@ -6152,13 +6145,13 @@ class Sku(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], + name: Union[str, "_models.SkuName"], **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName """ @@ -6208,17 +6201,17 @@ class SkuInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Possible values include: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_09_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Possible values include: "Storage", - "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -6253,14 +6246,14 @@ class SkuInformation(msrest.serialization.Model): def __init__( self, *, - name: Union[str, "SkuName"], - restrictions: Optional[List["Restriction"]] = None, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, **kwargs ): """ :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Possible values include: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if @@ -6307,7 +6300,7 @@ class SmbSetting(msrest.serialization.Model): def __init__( self, *, - multichannel: Optional["Multichannel"] = None, + multichannel: Optional["_models.Multichannel"] = None, versions: Optional[str] = None, authentication_methods: Optional[str] = None, kerberos_ticket_encryption: Optional[str] = None, @@ -6447,7 +6440,7 @@ class StorageAccount(TrackedResource): :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :ivar kind: Gets the Kind. Possible values include: "Storage", "StorageV2", "BlobStorage", + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar identity: The identity of the resource. @@ -6455,7 +6448,7 @@ class StorageAccount(TrackedResource): :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Possible values include: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_09_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6464,7 +6457,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Possible values include: "available", "unavailable". + account is available or unavailable. Known values are: "available", "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_09_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6476,7 +6469,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Possible values include: "available", "unavailable". + Standard_RAGRS. Known values are: "available", "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_09_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6498,7 +6491,7 @@ class StorageAccount(TrackedResource): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Possible values include: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6520,7 +6513,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6536,8 +6529,8 @@ class StorageAccount(TrackedResource): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6553,8 +6546,8 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -6563,7 +6556,7 @@ class StorageAccount(TrackedResource): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6571,8 +6564,8 @@ class StorageAccount(TrackedResource): ~azure.mgmt.storage.v2021_09_01.models.StorageAccountSkuConversionStatus :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an - Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Possible - values include: "Standard", "AzureDnsZone". + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ @@ -6660,26 +6653,26 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - extended_location: Optional["ExtendedLocation"] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, - storage_account_sku_conversion_status: Optional["StorageAccountSkuConversionStatus"] = None, - dns_endpoint_type: Optional[Union[str, "DnsEndpointType"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + storage_account_sku_conversion_status: Optional["_models.StorageAccountSkuConversionStatus"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, **kwargs ): """ @@ -6705,7 +6698,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6715,8 +6708,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6732,7 +6725,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -6742,7 +6735,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6751,7 +6744,7 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Possible values include: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard", "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) @@ -6846,7 +6839,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar sku: Required. Required. Gets or sets the SKU name. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Possible values include: + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar location: Required. Required. Gets or sets the location of the resource. This will be one @@ -6866,11 +6859,11 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :ivar sas_policy: SasPolicy assigned to the storage account. @@ -6889,7 +6882,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Possible values include: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6905,7 +6898,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6915,8 +6908,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6938,8 +6931,8 @@ class StorageAccountCreateParameters(msrest.serialization.Model): ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an - Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Possible - values include: "Standard", "AzureDnsZone". + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ @@ -6984,42 +6977,42 @@ class StorageAccountCreateParameters(msrest.serialization.Model): def __init__( self, *, - sku: "Sku", - kind: Union[str, "Kind"], + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], location: str, - extended_location: Optional["ExtendedLocation"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, is_hns_enabled: Optional[bool] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, enable_nfs_v3: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, - dns_endpoint_type: Optional[Union[str, "DnsEndpointType"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, **kwargs ): """ :keyword sku: Required. Required. Gets or sets the SKU name. :paramtype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Possible values - include: "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :keyword location: Required. Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, @@ -7038,10 +7031,10 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -7061,7 +7054,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Possible values include: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7077,7 +7070,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7087,8 +7080,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7111,7 +7104,7 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Possible values include: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard", "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ super(StorageAccountCreateParameters, self).__init__(**kwargs) @@ -7197,8 +7190,8 @@ class StorageAccountKey(msrest.serialization.Model): :vartype key_name: str :ivar value: Base 64-encoded value of the key. :vartype value: str - :ivar permissions: Permissions for the key -- read-only or full permissions. Possible values - include: "Read", "Full". + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime @@ -7382,12 +7375,12 @@ class StorageAccountSkuConversionStatus(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar sku_conversion_status: This property indicates the current sku conversion status. - Possible values include: "InProgress", "Succeeded", "Failed". + :ivar sku_conversion_status: This property indicates the current sku conversion status. Known + values are: "InProgress", "Succeeded", "Failed". :vartype sku_conversion_status: str or ~azure.mgmt.storage.v2021_09_01.models.SkuConversionStatus :ivar target_sku_name: This property represents the target sku name to which the account sku is - being converted asynchronously. Possible values include: "Standard_LRS", "Standard_GRS", + being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :vartype target_sku_name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName @@ -7413,12 +7406,12 @@ class StorageAccountSkuConversionStatus(msrest.serialization.Model): def __init__( self, *, - target_sku_name: Optional[Union[str, "SkuName"]] = None, + target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs ): """ :keyword target_sku_name: This property represents the target sku name to which the account sku - is being converted asynchronously. Possible values include: "Standard_LRS", "Standard_GRS", + is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS". :paramtype target_sku_name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName @@ -7444,8 +7437,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7461,7 +7454,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Possible values include: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7476,7 +7469,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_09_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7486,8 +7479,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): the storage account. The default interpretation is true for this property. :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. - The default interpretation is TLS 1.0 for this property. Possible values include: "TLS1_0", - "TLS1_1", "TLS1_2". + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7501,8 +7494,8 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: - "Enabled", "Disabled". + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true @@ -7511,12 +7504,12 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an - Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Possible - values include: "Standard", "AzureDnsZone". + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ @@ -7551,31 +7544,31 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): def __init__( self, *, - sku: Optional["Sku"] = None, + sku: Optional["_models.Sku"] = None, tags: Optional[Dict[str, str]] = None, - identity: Optional["Identity"] = None, - kind: Optional[Union[str, "Kind"]] = None, - custom_domain: Optional["CustomDomain"] = None, - encryption: Optional["Encryption"] = None, - sas_policy: Optional["SasPolicy"] = None, - key_policy: Optional["KeyPolicy"] = None, - access_tier: Optional[Union[str, "AccessTier"]] = None, - azure_files_identity_based_authentication: Optional["AzureFilesIdentityBasedAuthentication"] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, enable_https_traffic_only: Optional[bool] = None, is_sftp_enabled: Optional[bool] = None, is_local_user_enabled: Optional[bool] = None, - network_rule_set: Optional["NetworkRuleSet"] = None, - large_file_shares_state: Optional[Union[str, "LargeFileSharesState"]] = None, - routing_preference: Optional["RoutingPreference"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, allow_blob_public_access: Optional[bool] = None, - minimum_tls_version: Optional[Union[str, "MinimumTlsVersion"]] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, allow_shared_key_access: Optional[bool] = None, allow_cross_tenant_replication: Optional[bool] = None, default_to_o_auth_authentication: Optional[bool] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - immutable_storage_with_versioning: Optional["ImmutableStorageAccount"] = None, - allowed_copy_scope: Optional[Union[str, "AllowedCopyScope"]] = None, - dns_endpoint_type: Optional[Union[str, "DnsEndpointType"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, **kwargs ): """ @@ -7591,8 +7584,8 @@ def __init__( :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Possible values include: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7608,7 +7601,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Possible values include: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7624,7 +7617,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_09_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Possible values include: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled", "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7634,8 +7627,8 @@ def __init__( in the storage account. The default interpretation is true for this property. :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to - storage. The default interpretation is TLS 1.0 for this property. Possible values include: - "TLS1_0", "TLS1_1", "TLS1_2". + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7649,7 +7642,7 @@ def __init__( authentication is OAuth or not. The default interpretation is false for this property. :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. - Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Possible values include: + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -7659,12 +7652,12 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Possible values include: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Possible values include: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard", "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ super(StorageAccountUpdateParameters, self).__init__(**kwargs) @@ -7778,15 +7771,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_09_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_09_01.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -7805,25 +7798,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_09_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. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_09_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime @@ -7874,7 +7867,7 @@ class Table(Resource): def __init__( self, *, - signed_identifiers: Optional[List["TableSignedIdentifier"]] = None, + signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, **kwargs ): """ @@ -7969,7 +7962,7 @@ class TableServiceProperties(Resource): def __init__( self, *, - cors: Optional["CorsRules"] = None, + cors: Optional["_models.CorsRules"] = None, **kwargs ): """ @@ -8006,7 +7999,7 @@ def __init__( self, *, id: str, - access_policy: Optional["TableAccessPolicy"] = None, + access_policy: Optional["_models.TableAccessPolicy"] = None, **kwargs ): """ @@ -8124,7 +8117,7 @@ class UpdateHistoryProperty(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Possible values include: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", "extend". :vartype update: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -8211,7 +8204,7 @@ class Usage(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar unit: Gets the unit of measurement. Possible values include: "Count", "Bytes", "Seconds", + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_09_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. @@ -8263,7 +8256,7 @@ class UsageListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Usage"]] = None, + value: Optional[List["_models.Usage"]] = None, **kwargs ): """ @@ -8349,7 +8342,7 @@ class VirtualNetworkRule(msrest.serialization.Model): :ivar action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :vartype action: str - :ivar state: Gets the state of virtual network rule. Possible values include: "Provisioning", + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.State """ @@ -8369,7 +8362,7 @@ def __init__( *, virtual_network_resource_id: str, action: Optional[str] = None, - state: Optional[Union[str, "State"]] = None, + state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ @@ -8379,8 +8372,8 @@ def __init__( :keyword action: The action of virtual network rule. The only acceptable values to pass in are None and "Allow". The default value is None. :paramtype action: str - :keyword state: Gets the state of virtual network rule. Possible values include: - "Provisioning", "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.State """ super(VirtualNetworkRule, self).__init__(**kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py index 172440daedf9..84932f4dc478 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py @@ -7,11 +7,10 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. @@ -21,7 +20,7 @@ class AccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of @@ -34,7 +33,7 @@ class AccountImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str LOCKED = "Locked" DISABLED = "Disabled" -class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. """ @@ -42,14 +41,14 @@ class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AVAILABLE = "available" UNAVAILABLE = "unavailable" -class ActiveDirectoryPropertiesAccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ActiveDirectoryPropertiesAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the Active Directory account type for Azure Storage. """ USER = "User" COMPUTER = "Computer" -class AllowedCopyScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. """ @@ -57,11 +56,11 @@ class AllowedCopyScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): PRIVATE_LINK = "PrivateLink" AAD = "AAD" -class BlobInventoryPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. @@ -71,7 +70,7 @@ class BlobRestoreProgressStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enu COMPLETE = "Complete" FAILED = "Failed" -class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. @@ -82,7 +81,7 @@ class Bypass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" -class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETE = "DELETE" GET = "GET" @@ -93,7 +92,7 @@ class CorsRuleAllowedMethodsItem(with_metaclass(CaseInsensitiveEnumMeta, str, En PUT = "PUT" PATCH = "PATCH" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -102,14 +101,14 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the default action of allow or deny when no other rules match. """ ALLOW = "Allow" DENY = "Deny" -class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Default share permission for users using Kerberos authentication if RBAC role is not assigned. """ @@ -118,7 +117,7 @@ class DefaultSharePermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)) STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" -class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the directory service used. """ @@ -126,7 +125,7 @@ class DirectoryServiceOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) AADDS = "AADDS" AD = "AD" -class DnsEndpointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. @@ -135,7 +134,7 @@ class DnsEndpointType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" AZURE_DNS_ZONE = "AzureDnsZone" -class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. """ @@ -143,7 +142,7 @@ class EnabledProtocols(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SMB = "SMB" NFS = "NFS" -class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. """ @@ -151,33 +150,33 @@ class EncryptionScopeSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" -class EncryptionScopeState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. """ ENABLED = "Enabled" DISABLED = "Disabled" -class ExpirationAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SAS expiration action. Can only be Log. """ LOG = "Log" -class ExtendedLocationTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of extendedLocation. """ EDGE_ZONE = "EdgeZone" -class Format(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field, it specifies the format for the inventory files. """ CSV = "Csv" PARQUET = "Parquet" -class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when @@ -189,14 +188,14 @@ class GeoReplicationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" -class HttpProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The protocol permitted for a request made with the account SAS. """ HTTPS_HTTP = "https,http" HTTPS = "https" -class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The identity type. """ @@ -205,14 +204,14 @@ class IdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class ImmutabilityPolicyState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. """ @@ -221,20 +220,20 @@ class ImmutabilityPolicyUpdateType(with_metaclass(CaseInsensitiveEnumMeta, str, LOCK = "lock" EXTEND = "extend" -class InventoryRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Inventory """ INVENTORY = "Inventory" -class KeyPermission(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Permissions for the key -- read-only or full permissions. """ READ = "Read" FULL = "Full" -class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault """ @@ -242,7 +241,7 @@ class KeySource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is used. @@ -251,7 +250,7 @@ class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SERVICE = "Service" ACCOUNT = "Account" -class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates the type of storage account. """ @@ -261,14 +260,14 @@ class Kind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" -class LargeFileSharesState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. """ DISABLED = "Disabled" ENABLED = "Enabled" -class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -278,7 +277,7 @@ class LeaseContainerRequestAction(with_metaclass(CaseInsensitiveEnumMeta, str, E RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. """ @@ -286,7 +285,7 @@ class LeaseDuration(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): INFINITE = "Infinite" FIXED = "Fixed" -class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies the lease action. Can be one of the available actions. """ @@ -296,7 +295,7 @@ class LeaseShareAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RELEASE = "Release" BREAK_ENUM = "Break" -class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Lease state of the container. """ @@ -306,22 +305,22 @@ class LeaseState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BREAKING = "Breaking" BROKEN = "Broken" -class LeaseStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The lease status of the container. """ LOCKED = "Locked" UNLOCKED = "Unlocked" -class ListContainersInclude(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): DELETED = "deleted" -class ManagementPolicyName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): DEFAULT = "default" -class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. """ @@ -329,7 +328,7 @@ class MigrationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): IN_PROGRESS = "InProgress" COMPLETED = "Completed" -class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. """ @@ -338,13 +337,13 @@ class MinimumTlsVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" -class Name(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only """ ACCESS_TIME_TRACKING = "AccessTimeTracking" -class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. """ @@ -352,7 +351,7 @@ class ObjectType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" CONTAINER = "Container" -class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). """ @@ -366,7 +365,7 @@ class Permissions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): U = "u" P = "p" -class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The current provisioning state. """ @@ -375,7 +374,7 @@ class PrivateEndpointConnectionProvisioningState(with_metaclass(CaseInsensitiveE DELETING = "Deleting" FAILED = "Failed" -class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The private endpoint connection status. """ @@ -383,7 +382,7 @@ class PrivateEndpointServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumM APPROVED = "Approved" REJECTED = "Rejected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status of the storage account at the time the operation was called. """ @@ -391,7 +390,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" -class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether data in the container may be accessed publicly and the level of access. """ @@ -399,7 +398,7 @@ class PublicAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): BLOB = "Blob" NONE = "None" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. """ @@ -407,7 +406,7 @@ class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. """ @@ -415,7 +414,7 @@ class Reason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" -class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to @@ -425,7 +424,7 @@ class ReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" -class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The property is for NFS share only. The default is NoRootSquash. """ @@ -433,27 +432,27 @@ class RootSquashType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" -class RoutingChoice(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Routing Choice defines the kind of network routing opted by the user. """ MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" -class RuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The valid value is Lifecycle """ LIFECYCLE = "Lifecycle" -class Schedule(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field is used to schedule an inventory formation. """ DAILY = "Daily" WEEKLY = "Weekly" -class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). """ @@ -463,7 +462,7 @@ class Services(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): T = "t" F = "f" -class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. """ @@ -473,7 +472,7 @@ class ShareAccessTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): COOL = "Cool" PREMIUM = "Premium" -class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). """ @@ -483,7 +482,7 @@ class SignedResource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): F = "f" S = "s" -class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. @@ -493,7 +492,7 @@ class SignedResourceTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): C = "c" O = "o" -class SkuConversionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property indicates the current sku conversion status. """ @@ -501,7 +500,7 @@ class SkuConversionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SUCCEEDED = "Succeeded" FAILED = "Failed" -class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. """ @@ -515,14 +514,14 @@ class SkuName(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" -class SkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU tier. This is based on the SKU name. """ STANDARD = "Standard" PREMIUM = "Premium" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the state of virtual network rule. """ @@ -532,12 +531,12 @@ class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" -class StorageAccountExpand(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" -class UsageUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the unit of measurement. """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py index 4c1064ae3825..22f9808d440a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py @@ -27,6 +27,9 @@ from ._table_services_operations import TableServicesOperations from ._table_operations import TableOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'Operations', 'SkusOperations', @@ -49,3 +52,5 @@ 'TableServicesOperations', 'TableOperations', ] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py index 0da9358f71d4..d146683385d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -39,37 +39,39 @@ def build_list_request( include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -80,16 +82,19 @@ def build_create_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -97,23 +102,21 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,16 +129,19 @@ def build_update_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobContainer] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -143,23 +149,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -173,10 +177,14 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -184,21 +192,19 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -210,9 +216,11 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -220,16 +228,15 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -240,16 +247,19 @@ def build_set_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -257,23 +267,21 @@ def build_set_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -286,16 +294,19 @@ def build_clear_legal_hold_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LegalHold] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -303,23 +314,21 @@ def build_clear_legal_hold_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -332,18 +341,21 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - immutability_policy_name = "default" - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -352,25 +364,23 @@ def build_create_or_update_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -386,11 +396,15 @@ def build_get_immutability_policy_request( if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -399,23 +413,21 @@ def build_get_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -429,11 +441,15 @@ def build_delete_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - immutability_policy_name = "default" - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -442,22 +458,20 @@ def build_delete_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -471,10 +485,14 @@ def build_lock_immutability_policy_request( if_match: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -482,22 +500,20 @@ def build_lock_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -509,16 +525,19 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: JSONType = None, + json: Optional[_models.ImmutabilityPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -526,24 +545,22 @@ def build_extend_immutability_policy_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -556,16 +573,19 @@ def build_lease_request( container_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseContainerRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -573,23 +593,21 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -603,10 +621,14 @@ def build_object_level_worm_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -614,45 +636,41 @@ def build_object_level_worm_request_initial( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobContainersOperations(object): - """BlobContainersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`blob_containers` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -663,7 +681,7 @@ def list( filter: Optional[str] = None, include: Optional[Union[str, "_models.ListContainersInclude"]] = None, **kwargs: Any - ) -> Iterable["_models.ListContainerItems"]: + ) -> Iterable[_models.ListContainerItems]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. @@ -675,23 +693,29 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in - the list. + the list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only container names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListContainerItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListContainerItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -699,13 +723,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -713,13 +740,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -733,7 +763,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -746,7 +780,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore @distributed_trace def create( @@ -754,9 +788,9 @@ def create( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for that container. It does not include a list of the blobs contained by the container. @@ -780,13 +814,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -795,14 +833,21 @@ def create( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -820,7 +865,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -829,9 +874,9 @@ def update( resource_group_name: str, account_name: str, container_name: str, - blob_container: "_models.BlobContainer", + blob_container: _models.BlobContainer, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. @@ -854,13 +899,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobContainer] _json = self._serialize.body(blob_container, 'BlobContainer') @@ -869,14 +918,21 @@ def update( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -890,7 +946,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -900,7 +956,7 @@ def get( account_name: str, container_name: str, **kwargs: Any - ) -> "_models.BlobContainer": + ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -920,11 +976,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobContainer"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] request = build_get_request( @@ -932,12 +993,19 @@ def get( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -951,11 +1019,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -981,11 +1049,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -993,12 +1066,19 @@ def delete( account_name=account_name, container_name=container_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1008,7 +1088,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace @@ -1017,9 +1097,9 @@ def set_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear out the existing tags that are not specified in the request. @@ -1043,13 +1123,17 @@ def set_legal_hold( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1058,14 +1142,21 @@ def set_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,7 +1170,7 @@ def set_legal_hold( return deserialized - set_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold'} # type: ignore + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore @distributed_trace @@ -1088,9 +1179,9 @@ def clear_legal_hold( resource_group_name: str, account_name: str, container_name: str, - legal_hold: "_models.LegalHold", + legal_hold: _models.LegalHold, **kwargs: Any - ) -> "_models.LegalHold": + ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. @@ -1113,13 +1204,17 @@ def clear_legal_hold( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LegalHold"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LegalHold] _json = self._serialize.body(legal_hold, 'LegalHold') @@ -1128,14 +1223,21 @@ def clear_legal_hold( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1149,7 +1251,7 @@ def clear_legal_hold( return deserialized - clear_legal_hold.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold'} # type: ignore + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore @distributed_trace @@ -1159,9 +1261,9 @@ def create_or_update_immutability_policy( account_name: str, container_name: str, if_match: Optional[str] = None, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. @@ -1179,23 +1281,32 @@ def create_or_update_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1207,15 +1318,23 @@ def create_or_update_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, content_type=content_type, json=_json, if_match=if_match, template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1232,7 +1351,7 @@ def create_or_update_immutability_policy( return deserialized - create_or_update_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1243,7 +1362,7 @@ def get_immutability_policy( container_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Gets the existing immutability policy along with the corresponding ETag in response headers and body. @@ -1261,18 +1380,28 @@ def get_immutability_policy( :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Default value is None. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_get_immutability_policy_request( @@ -1280,13 +1409,21 @@ def get_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1303,7 +1440,7 @@ def get_immutability_policy( return deserialized - get_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1314,7 +1451,7 @@ def delete_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this operation. Deleting a locked immutability policy is not allowed, the only way is to delete the @@ -1336,16 +1473,26 @@ def delete_immutability_policy( of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_delete_immutability_policy_request( @@ -1353,13 +1500,21 @@ def delete_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, if_match=if_match, template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1376,7 +1531,7 @@ def delete_immutability_policy( return deserialized - delete_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}'} # type: ignore + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace @@ -1387,7 +1542,7 @@ def lock_immutability_policy( container_name: str, if_match: str, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. @@ -1412,11 +1567,16 @@ def lock_immutability_policy( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] request = build_lock_immutability_policy_request( @@ -1424,13 +1584,20 @@ def lock_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, if_match=if_match, template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1447,7 +1614,7 @@ def lock_immutability_policy( return deserialized - lock_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock'} # type: ignore + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore @distributed_trace @@ -1457,9 +1624,9 @@ def extend_immutability_policy( account_name: str, container_name: str, if_match: str, - parameters: Optional["_models.ImmutabilityPolicy"] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, **kwargs: Any - ) -> "_models.ImmutabilityPolicy": + ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy will be this action. ETag in If-Match is required for this operation. @@ -1481,20 +1648,24 @@ def extend_immutability_policy( omitted, this operation will always be applied. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob - container. + container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :keyword callable cls: A custom type or function that will be passed the direct response :return: ImmutabilityPolicy, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ImmutabilityPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ImmutabilityPolicy] if parameters is not None: _json = self._serialize.body(parameters, 'ImmutabilityPolicy') @@ -1506,15 +1677,22 @@ def extend_immutability_policy( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, if_match=if_match, json=_json, template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1531,7 +1709,7 @@ def extend_immutability_policy( return deserialized - extend_immutability_policy.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend'} # type: ignore + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore @distributed_trace @@ -1540,9 +1718,9 @@ def lease( resource_group_name: str, account_name: str, container_name: str, - parameters: Optional["_models.LeaseContainerRequest"] = None, + parameters: Optional[_models.LeaseContainerRequest] = None, **kwargs: Any - ) -> "_models.LeaseContainerResponse": + ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -1558,20 +1736,24 @@ def lease( letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type container_name: str - :param parameters: Lease Container request body. + :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseContainerResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseContainerResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LeaseContainerResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseContainerRequest') @@ -1583,14 +1765,21 @@ def lease( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1604,21 +1793,26 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - def _object_level_worm_initial( + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_object_level_worm_request_initial( @@ -1626,12 +1820,19 @@ def _object_level_worm_initial( account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1641,11 +1842,11 @@ def _object_level_worm_initial( if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( + def begin_object_level_worm( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1681,19 +1882,26 @@ def begin_object_level_worm( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = self._object_level_worm_initial( + raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1703,8 +1911,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1713,7 +1927,6 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate'} # type: ignore + begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py index f9eb0edf59d1..9df37dbd9c00 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -34,10 +34,14 @@ def build_get_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -45,21 +49,19 @@ def build_get_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -70,16 +72,19 @@ def build_create_or_update_request( subscription_id: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], *, - json: JSONType = None, + json: Optional[_models.BlobInventoryPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -87,23 +92,21 @@ def build_create_or_update_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -117,10 +120,14 @@ def build_delete_request( blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -128,21 +135,19 @@ def build_delete_request( "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -153,55 +158,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobInventoryPoliciesOperations(object): - """BlobInventoryPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -210,7 +215,7 @@ def get( account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -229,11 +234,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] request = build_get_request( @@ -241,12 +251,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -260,7 +277,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -269,9 +286,9 @@ def create_or_update( resource_group_name: str, account_name: str, blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - properties: "_models.BlobInventoryPolicy", + properties: _models.BlobInventoryPolicy, **kwargs: Any - ) -> "_models.BlobInventoryPolicy": + ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -292,13 +309,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobInventoryPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobInventoryPolicy] _json = self._serialize.body(properties, 'BlobInventoryPolicy') @@ -307,14 +328,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,11 +356,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -357,11 +385,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -369,12 +402,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -384,7 +424,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace @@ -393,7 +433,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListBlobInventoryPolicy"]: + ) -> Iterable[_models.ListBlobInventoryPolicy]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -410,11 +450,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListBlobInventoryPolicy] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListBlobInventoryPolicy"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -422,10 +467,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -433,10 +481,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,7 +501,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -464,4 +519,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py index 346daa9dcc72..a4865acd736b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -67,17 +69,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - blob_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -85,23 +90,21 @@ def build_set_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,11 +117,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - blob_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,45 +133,41 @@ def build_get_service_properties_request( "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class BlobServicesOperations(object): - """BlobServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`blob_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -172,7 +175,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.BlobServiceItems"]: + ) -> Iterable[_models.BlobServiceItems]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +190,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -199,10 +207,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -210,10 +221,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -227,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -240,16 +258,16 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore @distributed_trace def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobServiceProperties", + parameters: _models.BlobServiceProperties, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -263,18 +281,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] _json = self._serialize.body(parameters, 'BlobServiceProperties') @@ -282,14 +309,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -303,7 +338,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace @@ -312,7 +347,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.BlobServiceProperties": + ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -323,28 +358,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: BlobServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -358,5 +411,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py index d4858c579e50..384cb183eaf9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,29 +31,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -63,61 +66,61 @@ def build_get_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long path_format_arguments = { "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), "location": _SERIALIZER.url("location", location, 'str'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class DeletedAccountsOperations(object): - """DeletedAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`deleted_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.DeletedAccountListResult"]: + ) -> Iterable[_models.DeletedAccountListResult]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -127,29 +130,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -163,7 +177,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +195,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace def get( @@ -185,7 +203,7 @@ def get( deleted_account_name: str, location: str, **kwargs: Any - ) -> "_models.DeletedAccount": + ) -> _models.DeletedAccount: """Get properties of specified deleted account resource. :param deleted_account_name: Name of the deleted storage account. @@ -197,23 +215,35 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DeletedAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -228,5 +258,5 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py index 77d6afc79b37..e2c076749b2d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_put_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_put_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_patch_request( subscription_id: str, encryption_scope_name: str, *, - json: JSONType = None, + json: Optional[_models.EncryptionScope] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_patch_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( encryption_scope_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -162,55 +166,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class EncryptionScopesOperations(object): - """EncryptionScopesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def put( @@ -218,9 +222,9 @@ def put( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. @@ -244,13 +248,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -259,14 +267,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -285,7 +300,7 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -294,9 +309,9 @@ def patch( resource_group_name: str, account_name: str, encryption_scope_name: str, - encryption_scope: "_models.EncryptionScope", + encryption_scope: _models.EncryptionScope, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. @@ -319,13 +334,17 @@ def patch( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.EncryptionScope] _json = self._serialize.body(encryption_scope, 'EncryptionScope') @@ -334,14 +353,21 @@ def patch( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.patch.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -356,7 +382,7 @@ def patch( return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -366,7 +392,7 @@ def get( account_name: str, encryption_scope_name: str, **kwargs: Any - ) -> "_models.EncryptionScope": + ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -386,11 +412,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScope"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] request = build_get_request( @@ -398,12 +429,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,7 +456,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace @@ -427,7 +465,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.EncryptionScopeListResult"]: + ) -> Iterable[_models.EncryptionScopeListResult]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -444,11 +482,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EncryptionScopeListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -456,10 +499,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -467,10 +513,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -484,7 +533,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -497,4 +550,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py index a12fc58d1e14..2ef980142a62 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - file_services_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - file_services_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class FileServicesOperations(object): - """FileServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`file_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceItems": + ) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceItems"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.FileServiceProperties", + parameters: _models.FileServiceProperties, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] _json = self._serialize.body(parameters, 'FileServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.FileServiceProperties": + ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py index c98ecd40a742..15448b525c26 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -37,37 +37,39 @@ def build_list_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -78,17 +80,20 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,25 +101,23 @@ def build_create_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -127,16 +130,19 @@ def build_update_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.FileShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -144,23 +150,21 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -177,10 +181,14 @@ def build_get_request( x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -188,25 +196,23 @@ def build_get_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -221,10 +227,14 @@ def build_delete_request( include: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -232,25 +242,23 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if include is not None: - query_parameters['$include'] = _SERIALIZER.query("include", include, 'str') + _params['$include'] = _SERIALIZER.query("include", include, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,16 +269,19 @@ def build_restore_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.DeletedShare] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -278,23 +289,21 @@ def build_restore_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -307,17 +316,20 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.LeaseShareRequest] = None, content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -325,51 +337,47 @@ def build_lease_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if x_ms_snapshot is not None: - header_parameters['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class FileSharesOperations(object): - """FileSharesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`file_shares` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -380,7 +388,7 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.FileShareItems"]: + ) -> Iterable[_models.FileShareItems]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -391,24 +399,30 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the - list. + list. Default value is None. :type maxpagesize: str :param filter: Optional. When specified, only share names starting with the filter will be - listed. + listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: deleted, snapshots. Should be passed as a string with delimiter ','. + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FileShareItems or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItems] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShareItems"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -416,13 +430,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -430,13 +447,16 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -450,7 +470,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -463,7 +487,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore @distributed_trace def create( @@ -471,10 +495,10 @@ def create( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. It does not include a list of the files contained by the share. @@ -494,20 +518,24 @@ def create( :param file_share: Properties of the file share to create. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values - are: snapshots. Should be passed as a string with delimiter ','. + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -516,15 +544,22 @@ def create( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, expand=expand, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -542,7 +577,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -551,9 +586,9 @@ def update( resource_group_name: str, account_name: str, share_name: str, - file_share: "_models.FileShare", + file_share: _models.FileShare, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. @@ -576,13 +611,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.FileShare] _json = self._serialize.body(file_share, 'FileShare') @@ -591,14 +630,21 @@ def update( account_name=account_name, share_name=share_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -612,7 +658,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace @@ -624,7 +670,7 @@ def get( expand: Optional[str] = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any - ) -> "_models.FileShare": + ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -640,20 +686,26 @@ def get( or number. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values - are: stats. Should be passed as a string with delimiter ','. + are: stats. Should be passed as a string with delimiter ','. Default value is None. :type expand: str - :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response :return: FileShare, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.FileShare"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] request = build_get_request( @@ -661,14 +713,21 @@ def get( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -682,11 +741,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -709,7 +768,7 @@ def delete( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional, used to delete a snapshot. + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all of its file share @@ -723,11 +782,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -735,14 +799,21 @@ def delete( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -752,16 +823,16 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def restore( + def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, - deleted_share: "_models.DeletedShare", + deleted_share: _models.DeletedShare, **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. @@ -785,13 +856,17 @@ def restore( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(deleted_share, 'DeletedShare') @@ -800,14 +875,21 @@ def restore( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -817,7 +899,7 @@ def restore( if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore'} # type: ignore + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore @distributed_trace @@ -827,9 +909,9 @@ def lease( account_name: str, share_name: str, x_ms_snapshot: Optional[str] = None, - parameters: Optional["_models.LeaseShareRequest"] = None, + parameters: Optional[_models.LeaseShareRequest] = None, **kwargs: Any - ) -> "_models.LeaseShareResponse": + ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. @@ -845,22 +927,27 @@ def lease( dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. :type share_name: str - :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. :type x_ms_snapshot: str - :param parameters: Lease Share request body. + :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: LeaseShareResponse, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LeaseShareResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LeaseShareResponse] if parameters is not None: _json = self._serialize.body(parameters, 'LeaseShareRequest') @@ -872,15 +959,22 @@ def lease( account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, x_ms_snapshot=x_ms_snapshot, template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,5 +991,5 @@ def lease( return deserialized - lease.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease'} # type: ignore + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py index df74bef32171..c5d6fede8671 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, username: str, *, - json: JSONType = None, + json: Optional[_models.LocalUser] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,21 +172,19 @@ def build_delete_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -189,10 +196,14 @@ def build_list_keys_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -200,21 +211,19 @@ def build_list_keys_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -226,10 +235,14 @@ def build_regenerate_password_request( username: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -237,45 +250,41 @@ def build_regenerate_password_request( "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class LocalUsersOperations(object): - """LocalUsersOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`local_users` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -283,7 +292,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.LocalUsers"]: + ) -> Iterable[_models.LocalUsers]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -298,11 +307,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUsers] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUsers"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -310,10 +324,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -321,10 +338,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -338,7 +358,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -352,7 +376,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace def get( @@ -361,7 +385,7 @@ def get( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -379,11 +403,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] request = build_get_request( @@ -391,12 +420,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -411,7 +447,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace @@ -420,9 +456,9 @@ def create_or_update( resource_group_name: str, account_name: str, username: str, - properties: "_models.LocalUser", + properties: _models.LocalUser, **kwargs: Any - ) -> "_models.LocalUser": + ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -442,13 +478,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUser"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.LocalUser] _json = self._serialize.body(properties, 'LocalUser') @@ -457,14 +497,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -479,11 +526,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -507,11 +554,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -519,12 +571,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -535,7 +594,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace @@ -545,7 +604,7 @@ def list_keys( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserKeys": + ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -563,11 +622,16 @@ def list_keys( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserKeys"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] request = build_list_keys_request( @@ -575,12 +639,19 @@ def list_keys( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -595,7 +666,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace @@ -605,7 +676,7 @@ def regenerate_password( account_name: str, username: str, **kwargs: Any - ) -> "_models.LocalUserRegeneratePasswordResult": + ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -623,11 +694,16 @@ def regenerate_password( :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.LocalUserRegeneratePasswordResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] request = build_regenerate_password_request( @@ -635,12 +711,19 @@ def regenerate_password( account_name=account_name, subscription_id=self._config.subscription_id, username=username, + api_version=api_version, template_url=self.regenerate_password.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -655,5 +738,5 @@ def regenerate_password( return deserialized - regenerate_password.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword'} # type: ignore + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py index ef37ca852555..d0225e59df8a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,10 +33,14 @@ def build_get_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -44,21 +48,19 @@ def build_get_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,16 +71,19 @@ def build_create_or_update_request( subscription_id: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], *, - json: JSONType = None, + json: Optional[_models.ManagementPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -86,23 +91,21 @@ def build_create_or_update_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -116,9 +119,11 @@ def build_delete_request( management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -126,40 +131,37 @@ def build_delete_request( "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) -class ManagementPoliciesOperations(object): - """ManagementPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`management_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -168,7 +170,7 @@ def get( account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -187,11 +189,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] request = build_get_request( @@ -199,12 +206,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -218,7 +232,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace @@ -227,9 +241,9 @@ def create_or_update( resource_group_name: str, account_name: str, management_policy_name: Union[str, "_models.ManagementPolicyName"], - properties: "_models.ManagementPolicy", + properties: _models.ManagementPolicy, **kwargs: Any - ) -> "_models.ManagementPolicy": + ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -250,13 +264,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ManagementPolicy] _json = self._serialize.body(properties, 'ManagementPolicy') @@ -265,14 +283,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -286,11 +311,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -315,11 +340,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -327,12 +357,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -342,5 +379,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py index 1fe116ad1cd0..230056334db6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_create_or_update_request( subscription_id: str, object_replication_policy_id: str, *, - json: JSONType = None, + json: Optional[_models.ObjectReplicationPolicy] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_create_or_update_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( object_replication_policy_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class ObjectReplicationPoliciesOperations(object): - """ObjectReplicationPoliciesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`object_replication_policies` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ObjectReplicationPolicies"]: + ) -> Iterable[_models.ObjectReplicationPolicies]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicies] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicies"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +300,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( @@ -289,7 +309,7 @@ def get( account_name: str, object_replication_policy_id: str, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -309,11 +329,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] request = build_get_request( @@ -321,12 +346,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -341,7 +373,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace @@ -350,9 +382,9 @@ def create_or_update( resource_group_name: str, account_name: str, object_replication_policy_id: str, - properties: "_models.ObjectReplicationPolicy", + properties: _models.ObjectReplicationPolicy, **kwargs: Any - ) -> "_models.ObjectReplicationPolicy": + ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -375,13 +407,17 @@ def create_or_update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ObjectReplicationPolicy"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ObjectReplicationPolicy] _json = self._serialize.body(properties, 'ObjectReplicationPolicy') @@ -390,14 +426,21 @@ def create_or_update( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -412,11 +455,11 @@ def create_or_update( return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -442,11 +485,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -454,12 +502,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -470,5 +525,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py index e09e06c60f83..489380c929cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request @@ -29,54 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Storage/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + ) -> Iterable[_models.OperationListResult]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -85,27 +86,38 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( + api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +131,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,4 +148,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Storage/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py index 3517bc26e28b..51296ec70728 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,31 +33,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -69,10 +71,14 @@ def build_get_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -80,21 +86,19 @@ def build_get_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -105,16 +109,19 @@ def build_put_request( subscription_id: str, private_endpoint_connection_name: str, *, - json: JSONType = None, + json: Optional[_models.PrivateEndpointConnection] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -122,23 +129,21 @@ def build_put_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -152,10 +157,14 @@ def build_delete_request( private_endpoint_connection_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -163,45 +172,41 @@ def build_delete_request( "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateEndpointConnectionsOperations(object): - """PrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -209,7 +214,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionListResult"]: + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -226,11 +231,16 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # 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', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -238,10 +248,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -249,10 +262,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -266,7 +282,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -279,7 +299,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( @@ -288,7 +308,7 @@ def get( account_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -306,11 +326,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] request = build_get_request( @@ -318,12 +343,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -338,7 +370,7 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace @@ -347,9 +379,9 @@ def put( resource_group_name: str, account_name: str, private_endpoint_connection_name: str, - properties: "_models.PrivateEndpointConnection", + properties: _models.PrivateEndpointConnection, **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -369,13 +401,17 @@ def put( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(properties, 'PrivateEndpointConnection') @@ -384,14 +420,21 @@ def put( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.put.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -406,11 +449,11 @@ def put( return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -434,11 +477,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -446,12 +494,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -462,5 +517,5 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py index 85a56ab1dc87..497cef43fd00 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +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 functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,55 +32,55 @@ def build_list_by_storage_account_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class PrivateLinkResourcesOperations(object): - """PrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_storage_account( @@ -87,7 +88,7 @@ def list_by_storage_account( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.PrivateLinkResourceListResult": + ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -102,23 +103,35 @@ def list_by_storage_account( :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkResourceListResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] request = build_list_by_storage_account_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -132,5 +145,5 @@ def list_by_storage_account( return deserialized - list_by_storage_account.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources'} # type: ignore + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py index 01f93fa6b94a..cd07d16df39a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, queue_name: str, *, - json: JSONType = None, + json: Optional[_models.StorageQueue] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( queue_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -202,59 +208,59 @@ def build_list_request( filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if maxpagesize is not None: - query_parameters['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') if filter is not None: - query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueOperations(object): - """QueueOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`queue` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -262,9 +268,9 @@ def create( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -286,13 +292,17 @@ def create( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -301,14 +311,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -322,7 +339,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -331,9 +348,9 @@ def update( resource_group_name: str, account_name: str, queue_name: str, - queue: "_models.StorageQueue", + queue: _models.StorageQueue, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -355,13 +372,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageQueue] _json = self._serialize.body(queue, 'StorageQueue') @@ -370,14 +391,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -391,7 +419,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -401,7 +429,7 @@ def get( account_name: str, queue_name: str, **kwargs: Any - ) -> "_models.StorageQueue": + ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -421,11 +449,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageQueue"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] request = build_get_request( @@ -433,12 +466,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -452,11 +492,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -482,11 +522,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -494,12 +539,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, queue_name=queue_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -509,7 +561,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace @@ -520,7 +572,7 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.ListQueueResource"]: + ) -> Iterable[_models.ListQueueResource]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -531,21 +583,26 @@ def list( lower-case letters only. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list - queue response. + queue response. Default value is None. :type maxpagesize: str :param filter: Optional, When specified, only the queues with a name starting with the given - filter will be listed. + filter will be listed. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListQueueResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueueResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -553,12 +610,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -566,12 +626,15 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, maxpagesize=maxpagesize, filter=filter, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -585,7 +648,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -598,4 +665,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py index 154f378b9c11..e4b9a0c85491 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.QueueServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - queue_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - queue_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class QueueServicesOperations(object): - """QueueServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`queue_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListQueueServices": + ) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListQueueServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.QueueServiceProperties", + parameters: _models.QueueServiceProperties, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Queue service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] _json = self._serialize.body(parameters, 'QueueServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.QueueServiceProperties": + ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: QueueServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QueueServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py index e733fb78f5ab..6735b0daa110 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -30,59 +31,59 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class SkusOperations(object): - """SkusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`skus` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageSkuListResult"]: + ) -> Iterable[_models.StorageSkuListResult]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -92,29 +93,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageSkuListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageSkuListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -128,7 +140,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -141,4 +157,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py index f28d0745f105..218fd3bbcce4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings +from 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 @@ -16,14 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,37 +32,38 @@ def build_check_name_availability_request( subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,39 +75,40 @@ def build_create_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountCreateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,25 +121,26 @@ def build_delete_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['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=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -150,33 +153,35 @@ def build_get_properties_request( expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -186,39 +191,40 @@ def build_update_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountUpdateParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -229,29 +235,31 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -261,30 +269,32 @@ def build_list_by_resource_group_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -297,33 +307,35 @@ def build_list_keys_request( expand: Optional[str] = "kerb", **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -333,39 +345,40 @@ def build_regenerate_key_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -377,39 +390,40 @@ def build_list_account_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.AccountSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -421,39 +435,40 @@ def build_list_service_sas_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.ServiceSasParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -466,25 +481,26 @@ def build_failover_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) @@ -497,32 +513,34 @@ def build_hierarchical_namespace_migration_request_initial( request_type: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - query_parameters['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -533,31 +551,33 @@ def build_abort_hierarchical_namespace_migration_request_initial( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -567,39 +587,40 @@ def build_restore_blob_ranges_request_initial( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.BlobRestoreParameters] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -612,56 +633,55 @@ def build_revoke_user_delegation_keys_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') return HttpRequest( method="POST", - url=url, - params=query_parameters, + url=_url, + params=_params, **kwargs ) -class StorageAccountsOperations(object): - """StorageAccountsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`storage_accounts` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def check_name_availability( self, - account_name: "_models.StorageAccountCheckNameAvailabilityParameters", + account_name: _models.StorageAccountCheckNameAvailabilityParameters, **kwargs: Any - ) -> "_models.CheckNameAvailabilityResult": + ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. @@ -674,26 +694,37 @@ def check_name_availability( :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -707,23 +738,27 @@ def check_name_availability( return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability'} # type: ignore + check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> Optional["_models.StorageAccount"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.StorageAccount"]] + ) -> Optional[_models.StorageAccount]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount]] _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') @@ -731,14 +766,21 @@ def _create_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -754,7 +796,7 @@ def _create_initial( return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -762,9 +804,9 @@ def begin_create( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountCreateParameters", + parameters: _models.StorageAccountCreateParameters, **kwargs: Any - ) -> LROPoller["_models.StorageAccount"]: + ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or @@ -792,35 +834,47 @@ def begin_create( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount] + 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_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('StorageAccount', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + 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( @@ -829,13 +883,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -855,23 +908,35 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -881,7 +946,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -891,7 +956,7 @@ def get_properties( account_name: str, expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. @@ -905,31 +970,43 @@ def get_properties( :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. + and blobRestoreStatus. Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccount, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -943,7 +1020,7 @@ def get_properties( return deserialized - get_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace @@ -951,9 +1028,9 @@ def update( self, resource_group_name: str, account_name: str, - parameters: "_models.StorageAccountUpdateParameters", + parameters: _models.StorageAccountUpdateParameters, **kwargs: Any - ) -> "_models.StorageAccount": + ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not @@ -977,13 +1054,17 @@ def update( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccount"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccount] _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') @@ -991,14 +1072,21 @@ def update( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1012,14 +1100,14 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1030,29 +1118,40 @@ def list( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1066,7 +1165,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1079,14 +1182,14 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( self, resource_group_name: str, **kwargs: Any - ) -> Iterable["_models.StorageAccountListResult"]: + ) -> Iterable[_models.StorageAccountListResult]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. @@ -1100,31 +1203,42 @@ def list_by_resource_group( ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + 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) + 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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1138,7 +1252,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1151,7 +1269,7 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts'} # type: ignore + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( @@ -1160,7 +1278,7 @@ def list_keys( account_name: str, expand: Optional[str] = "kerb", **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. @@ -1171,32 +1289,44 @@ def list_keys( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str - :param expand: Specifies type of the key to be listed. Possible value is kerb. The default - value is "kerb". + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: StorageAccountListKeysResult, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, expand=expand, template_url=self.list_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1210,7 +1340,7 @@ def list_keys( return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys'} # type: ignore + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore @distributed_trace @@ -1218,9 +1348,9 @@ def regenerate_key( self, resource_group_name: str, account_name: str, - regenerate_key: "_models.StorageAccountRegenerateKeyParameters", + regenerate_key: _models.StorageAccountRegenerateKeyParameters, **kwargs: Any - ) -> "_models.StorageAccountListKeysResult": + ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1239,13 +1369,17 @@ def regenerate_key( :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.StorageAccountListKeysResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.StorageAccountListKeysResult] _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') @@ -1253,14 +1387,21 @@ def regenerate_key( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1274,7 +1415,7 @@ def regenerate_key( return deserialized - regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey'} # type: ignore + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore @distributed_trace @@ -1282,9 +1423,9 @@ def list_account_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.AccountSasParameters", + parameters: _models.AccountSasParameters, **kwargs: Any - ) -> "_models.ListAccountSasResponse": + ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1301,13 +1442,17 @@ def list_account_sas( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListAccountSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ListAccountSasResponse] _json = self._serialize.body(parameters, 'AccountSasParameters') @@ -1315,14 +1460,21 @@ def list_account_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1336,7 +1488,7 @@ def list_account_sas( return deserialized - list_account_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas'} # type: ignore + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore @distributed_trace @@ -1344,9 +1496,9 @@ def list_service_sas( self, resource_group_name: str, account_name: str, - parameters: "_models.ServiceSasParameters", + parameters: _models.ServiceSasParameters, **kwargs: Any - ) -> "_models.ListServiceSasResponse": + ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1363,13 +1515,17 @@ def list_service_sas( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListServiceSasResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.ListServiceSasResponse] _json = self._serialize.body(parameters, 'ServiceSasParameters') @@ -1377,14 +1533,21 @@ def list_service_sas( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1398,32 +1561,44 @@ def list_service_sas( return deserialized - list_service_sas.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas'} # type: ignore + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - def _failover_initial( + def _failover_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_failover_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1433,11 +1608,11 @@ def _failover_initial( if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( + def begin_failover( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1466,18 +1641,25 @@ def begin_failover( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = self._failover_initial( + raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1487,8 +1669,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1497,36 +1685,47 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover'} # type: ignore + begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - def _hierarchical_namespace_migration_initial( + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, request_type=request_type, template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1536,11 +1735,11 @@ def _hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( + def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1573,19 +1772,26 @@ def begin_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = self._hierarchical_namespace_migration_initial( + raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1595,8 +1801,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1605,34 +1817,45 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration'} # type: ignore + begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - def _abort_hierarchical_namespace_migration_initial( + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_abort_hierarchical_namespace_migration_request_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1642,11 +1865,11 @@ def _abort_hierarchical_namespace_migration_initial( if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( + def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1673,18 +1896,25 @@ def begin_abort_hierarchical_namespace_migration( :rtype: ~azure.core.polling.LROPoller[None] :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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] if cont_token is None: - raw_result = self._abort_hierarchical_namespace_migration_initial( + raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, + api_version=api_version, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) @@ -1694,8 +1924,14 @@ def get_long_running_output(pipeline_response): return cls(pipeline_response, None, {}) - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1704,25 +1940,28 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration'} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> "_models.BlobRestoreStatus": - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + ) -> _models.BlobRestoreStatus: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobRestoreStatus] _json = self._serialize.body(parameters, 'BlobRestoreParameters') @@ -1730,14 +1969,21 @@ def _restore_blob_ranges_initial( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1755,7 +2001,7 @@ def _restore_blob_ranges_initial( return deserialized - _restore_blob_ranges_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace @@ -1763,9 +2009,9 @@ def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, - parameters: "_models.BlobRestoreParameters", + parameters: _models.BlobRestoreParameters, **kwargs: Any - ) -> LROPoller["_models.BlobRestoreStatus"]: + ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -1790,35 +2036,47 @@ def begin_restore_blob_ranges( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] :raises: ~azure.core.exceptions.HttpResponseError """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.BlobRestoreStatus"] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( + raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_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): - response = pipeline_response.http_response deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1827,13 +2085,12 @@ def get_long_running_output(pipeline_response): client=self._client, deserialization_callback=get_long_running_output ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges'} # type: ignore + begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace - def revoke_user_delegation_keys( + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -1853,23 +2110,35 @@ def revoke_user_delegation_keys( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_revoke_user_delegation_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, template_url=self.revoke_user_delegation_keys.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1879,5 +2148,5 @@ def revoke_user_delegation_keys( if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys'} # type: ignore + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py index de206e0b500b..a975b6cbd892 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,13 +16,12 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,16 +33,19 @@ def build_create_request( subscription_id: str, table_name: str, *, - json: JSONType = None, + json: Optional[_models.Table] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -50,23 +53,21 @@ def build_create_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -79,16 +80,19 @@ def build_update_request( subscription_id: str, table_name: str, *, - json: JSONType = None, + json: Optional[_models.Table] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -96,23 +100,21 @@ def build_update_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -126,10 +128,14 @@ def build_get_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -137,21 +143,19 @@ def build_get_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -163,10 +167,14 @@ def build_delete_request( table_name: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -174,21 +182,19 @@ def build_delete_request( "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -199,55 +205,55 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableOperations(object): - """TableOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`table` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def create( @@ -255,9 +261,9 @@ def create( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional["_models.Table"] = None, + parameters: Optional[_models.Table] = None, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -271,20 +277,24 @@ def create( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. :type table_name: str - :param parameters: The parameters to provide to create a table. + :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.Table] if parameters is not None: _json = self._serialize.body(parameters, 'Table') @@ -296,14 +306,21 @@ def create( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, content_type=content_type, json=_json, template_url=self.create.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -317,7 +334,7 @@ def create( return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -326,9 +343,9 @@ def update( resource_group_name: str, account_name: str, table_name: str, - parameters: Optional["_models.Table"] = None, + parameters: Optional[_models.Table] = None, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -342,20 +359,24 @@ def update( and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin with a numeric character. :type table_name: str - :param parameters: The parameters to provide to create a table. + :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table :keyword callable cls: A custom type or function that will be passed the direct response :return: Table, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-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.Table] if parameters is not None: _json = self._serialize.body(parameters, 'Table') @@ -367,14 +388,21 @@ def update( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + 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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -388,7 +416,7 @@ def update( return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -398,7 +426,7 @@ def get( account_name: str, table_name: str, **kwargs: Any - ) -> "_models.Table": + ) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -417,11 +445,16 @@ def get( :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Table"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] request = build_get_request( @@ -429,12 +462,19 @@ def get( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,11 +488,11 @@ def get( return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, @@ -477,11 +517,16 @@ def delete( :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] request = build_delete_request( @@ -489,12 +534,19 @@ def delete( account_name=account_name, subscription_id=self._config.subscription_id, table_name=table_name, + api_version=api_version, template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: @@ -504,7 +556,7 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}'} # type: ignore + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace @@ -513,7 +565,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> Iterable["_models.ListTableResource"]: + ) -> Iterable[_models.ListTableResource]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -528,11 +580,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListTableResource] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableResource"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -540,10 +597,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -551,10 +611,13 @@ def prepare_request(next_link=None): resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -568,7 +631,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -581,4 +648,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py index ec1af66da014..6d129544cdfa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from 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.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -32,31 +32,33 @@ def build_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) @@ -66,17 +68,20 @@ def build_set_service_properties_request( account_name: str, subscription_id: str, *, - json: JSONType = None, + json: Optional[_models.TableServiceProperties] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - api_version = "2021-09-01" - table_service_name = "default" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -84,23 +89,21 @@ def build_set_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -113,11 +116,15 @@ def build_get_service_properties_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - table_service_name = "default" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long path_format_arguments = { "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), @@ -125,45 +132,41 @@ def build_get_service_properties_request( "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class TableServicesOperations(object): - """TableServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`table_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( @@ -171,7 +174,7 @@ def list( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.ListTableServices": + ) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The @@ -186,23 +189,35 @@ def list( :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListTableServices"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] request = build_list_request( resource_group_name=resource_group_name, account_name=account_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) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -216,7 +231,7 @@ def list( return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore @distributed_trace @@ -224,9 +239,9 @@ def set_service_properties( self, resource_group_name: str, account_name: str, - parameters: "_models.TableServiceProperties", + parameters: _models.TableServiceProperties, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -240,18 +255,27 @@ def set_service_properties( :param parameters: The properties of a storage account’s Table service, only properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] _json = self._serialize.body(parameters, 'TableServiceProperties') @@ -259,14 +283,22 @@ def set_service_properties( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, content_type=content_type, json=_json, template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,7 +312,7 @@ def set_service_properties( return deserialized - set_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace @@ -289,7 +321,7 @@ def get_service_properties( resource_group_name: str, account_name: str, **kwargs: Any - ) -> "_models.TableServiceProperties": + ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. @@ -300,28 +332,46 @@ def get_service_properties( Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: TableServiceProperties, or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.TableServiceProperties"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -335,5 +385,5 @@ def get_service_properties( return deserialized - get_service_properties.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}'} # type: ignore + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py index d44d4b5dea6f..0b404a62faea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,9 +6,9 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings +from 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 @@ -15,8 +16,8 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models from .._vendor import _convert_request, _format_url_section @@ -31,61 +32,61 @@ def build_list_by_location_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-09-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + accept = _headers.pop('Accept', "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), "location": _SERIALIZER.url("location", location, 'str'), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", - url=url, - params=query_parameters, - headers=header_parameters, + url=_url, + params=_params, + headers=_headers, **kwargs ) -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.storage.v2021_09_01.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2021_09_01.StorageManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list_by_location( self, location: str, **kwargs: Any - ) -> Iterable["_models.UsageListResult"]: + ) -> Iterable[_models.UsageListResult]: """Gets the current usage count and the limit for the resources of the location under the subscription. @@ -96,31 +97,42 @@ def list_by_location( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.UsageListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.UsageListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=self.list_by_location.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_by_location_request( subscription_id=self._config.subscription_id, location=location, + api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -134,7 +146,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -147,4 +163,4 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages'} # type: ignore + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py new file mode 100644 index 000000000000..317c71b53775 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py @@ -0,0 +1,23 @@ +# 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 ._storage_management_client import StorageManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py new file mode 100644 index 000000000000..dce8613e5ba5 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-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: + super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json new file mode 100644 index 000000000000..dec2d3cd88d4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json @@ -0,0 +1,121 @@ +{ + "chosen_version": "2022-05-01", + "total_api_version_list": ["2022-05-01"], + "client": { + "name": "StorageManagementClient", + "filename": "_storage_management_client", + "description": "The Azure Storage Management API.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "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\": [\"StorageManagementClientConfiguration\"]}, \"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\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "skus": "SkusOperations", + "storage_accounts": "StorageAccountsOperations", + "deleted_accounts": "DeletedAccountsOperations", + "usages": "UsagesOperations", + "management_policies": "ManagementPoliciesOperations", + "blob_inventory_policies": "BlobInventoryPoliciesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "object_replication_policies": "ObjectReplicationPoliciesOperations", + "local_users": "LocalUsersOperations", + "encryption_scopes": "EncryptionScopesOperations", + "blob_services": "BlobServicesOperations", + "blob_containers": "BlobContainersOperations", + "file_services": "FileServicesOperations", + "file_shares": "FileSharesOperations", + "queue_services": "QueueServicesOperations", + "queue": "QueueOperations", + "table_services": "TableServicesOperations", + "table": "TableOperations" + } +} \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py new file mode 100644 index 000000000000..c1d123697fce --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py @@ -0,0 +1,200 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import StorageManagementClientConfiguration +from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class StorageManagementClient: # pylint: disable=too-many-instance-attributes + """The Azure Storage Management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2022_05_01.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2022_05_01.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: azure.mgmt.storage.v2022_05_01.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: azure.mgmt.storage.v2022_05_01.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2022_05_01.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2022_05_01.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2022_05_01.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2022_05_01.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2022_05_01.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2022_05_01.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2022_05_01.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2022_05_01.operations.EncryptionScopesOperations + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2022_05_01.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: azure.mgmt.storage.v2022_05_01.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2022_05_01.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2022_05_01.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2022_05_01.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2022_05_01.operations.QueueOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2022_05_01.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2022_05_01.operations.TableOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> StorageManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py new file mode 100644 index 000000000000..aee9e7ff7ef2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "20.1.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py new file mode 100644 index 000000000000..d763454b9494 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py @@ -0,0 +1,20 @@ +# 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 ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['StorageManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py new file mode 100644 index 000000000000..9ec42f7e94a0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py @@ -0,0 +1,72 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-05-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: + super(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-05-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py new file mode 100644 index 000000000000..b4faeb5a4346 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py @@ -0,0 +1,200 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import StorageManagementClientConfiguration +from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class StorageManagementClient: # pylint: disable=too-many-instance-attributes + """The Azure Storage Management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2022_05_01.aio.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2022_05_01.aio.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: + azure.mgmt.storage.v2022_05_01.aio.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: + azure.mgmt.storage.v2022_05_01.aio.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2022_05_01.aio.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2022_05_01.aio.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2022_05_01.aio.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2022_05_01.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2022_05_01.aio.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2022_05_01.aio.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2022_05_01.aio.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2022_05_01.aio.operations.EncryptionScopesOperations + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2022_05_01.aio.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: + azure.mgmt.storage.v2022_05_01.aio.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2022_05_01.aio.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2022_05_01.aio.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2022_05_01.aio.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2022_05_01.aio.operations.QueueOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2022_05_01.aio.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2022_05_01.aio.operations.TableOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-05-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.skus = SkusOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + 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.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_containers = BlobContainersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_services = FileServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.file_shares = FileSharesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue_services = QueueServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.queue = QueueOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table_services = TableServicesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.table = TableOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "StorageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py new file mode 100644 index 000000000000..22f9808d440a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'SkusOperations', + 'StorageAccountsOperations', + 'DeletedAccountsOperations', + 'UsagesOperations', + 'ManagementPoliciesOperations', + 'BlobInventoryPoliciesOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', + 'ObjectReplicationPoliciesOperations', + 'LocalUsersOperations', + 'EncryptionScopesOperations', + 'BlobServicesOperations', + 'BlobContainersOperations', + 'FileServicesOperations', + 'FileSharesOperations', + 'QueueServicesOperations', + 'QueueOperations', + 'TableServicesOperations', + 'TableOperations', +] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..cac3e69eb52e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py @@ -0,0 +1,1307 @@ +# 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._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`blob_containers` 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, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + **kwargs: Any + ) -> AsyncIterable[_models.ListContainerItems]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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("ListContainerItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param blob_container: Properties of the blob container to create. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-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.BlobContainer] + + _json = self._serialize.body(blob_container, 'BlobContainer') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.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) + + if response.status_code == 200: + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param blob_container: Properties to update for the blob container. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-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.BlobContainer] + + _json = self._serialize.body(blob_container, 'BlobContainer') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LegalHold, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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-05-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.LegalHold] + + _json = self._serialize.body(legal_hold, 'LegalHold') + + request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LegalHold', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LegalHold, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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-05-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.LegalHold] + + _json = self._serialize.body(legal_hold, 'LegalHold') + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LegalHold', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-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.ImmutabilityPolicy] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + else: + _json = None + + request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace_async + async def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + if_match=if_match, + template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + if_match=if_match, + template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace_async + async def lock_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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-05-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.ImmutabilityPolicy] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + else: + _json = None + + request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LeaseContainerResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :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-05-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.LeaseContainerResponse] + + if parameters is not None: + _json = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore + + + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_object_level_worm_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + + + @distributed_trace_async + async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_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-05-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] + if cont_token is None: + raw_result = await self._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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, + lro_options={'final-state-via': 'location'}, + + **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_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..d3dfc9a81cf0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,358 @@ +# 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 + +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._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + properties: _models.BlobInventoryPolicy, + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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-05-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.BlobInventoryPolicy] + + _json = self._serialize.body(properties, 'BlobInventoryPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListBlobInventoryPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListBlobInventoryPolicy] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ListBlobInventoryPolicy", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py new file mode 100644 index 000000000000..18e45f665e30 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py @@ -0,0 +1,291 @@ +# 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._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`blob_services` 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, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.BlobServiceItems]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlobServiceItems or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("BlobServiceItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] + + _json = self._serialize.body(parameters, 'BlobServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + + + @distributed_trace_async + async def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..8bcd18e42483 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py @@ -0,0 +1,190 @@ +# 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._deleted_accounts_operations import build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` 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.DeletedAccountListResult]: + """Lists deleted accounts under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("DeletedAccountListResult", 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.Storage/deletedAccounts"} # type: ignore + + @distributed_trace_async + async def get( + self, + deleted_account_name: str, + location: str, + **kwargs: Any + ) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. + :type deleted_account_name: str + :param location: The location of the deleted storage account. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + + + request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + 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('DeletedAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..d7d3923acc59 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py @@ -0,0 +1,381 @@ +# 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._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-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.EncryptionScope] + + _json = self._serialize.body(encryption_scope, 'EncryptionScope') + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.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) + + if response.status_code == 200: + deserialized = self._deserialize('EncryptionScope', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-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.EncryptionScope] + + _json = self._serialize.body(encryption_scope, 'EncryptionScope') + + request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.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('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + 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('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.EncryptionScopeListResult]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EncryptionScopeListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("EncryptionScopeListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py new file mode 100644 index 000000000000..fcd6a55b3791 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py @@ -0,0 +1,263 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`file_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceItems, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceItems', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] + + _json = self._serialize.body(parameters, 'FileServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + + + @distributed_trace_async + async def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py new file mode 100644 index 000000000000..0c3b201ef2e9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py @@ -0,0 +1,661 @@ +# 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._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`file_shares` 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, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.FileShareItems]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FileShareItems or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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("FileShareItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param file_share: Properties of the file share to create. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-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.FileShare] + + _json = self._serialize.body(file_share, 'FileShare') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + expand=expand, + template_url=self.create.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) + + if response.status_code == 200: + deserialized = self._deserialize('FileShare', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param file_share: Properties to update for the file share. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-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.FileShare] + + _json = self._serialize.body(file_share, 'FileShare') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. + :type include: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + x_ms_snapshot=x_ms_snapshot, + include=include, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param deleted_share: + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare + :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-05-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] + + _json = self._serialize.body(deleted_share, 'DeletedShare') + + request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LeaseShareResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :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-05-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.LeaseShareResponse] + + if parameters is not None: + _json = self._serialize.body(parameters, 'LeaseShareRequest') + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + x_ms_snapshot=x_ms_snapshot, + template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py new file mode 100644 index 000000000000..ff765c42b371 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py @@ -0,0 +1,501 @@ +# 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._local_users_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_keys_request, build_list_request, build_regenerate_password_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`local_users` 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, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.LocalUsers]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalUsers or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUsers] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("LocalUsers", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUser', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :param properties: The local user associated with a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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-05-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.LocalUser] + + _json = self._serialize.body(properties, 'LocalUser') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUser', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace_async + async def list_keys( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserKeys, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUserKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore + + + @distributed_trace_async + async def regenerate_password( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + + + request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + api_version=api_version, + template_url=self.regenerate_password.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('LocalUserRegeneratePasswordResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py new file mode 100644 index 000000000000..af57d193439e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`management_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + properties: _models.ManagementPolicy, + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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-05-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.ManagementPolicy] + + _json = self._serialize.body(properties, 'ManagementPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..b2528239279b --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py @@ -0,0 +1,365 @@ +# 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._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` 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, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ObjectReplicationPolicies or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicies] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ObjectReplicationPolicies", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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('ObjectReplicationPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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-05-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.ObjectReplicationPolicy] + + _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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('ObjectReplicationPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py new file mode 100644 index 000000000000..7db82693bbb5 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py @@ -0,0 +1,121 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationListResult]: + """Lists all of the available Storage 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.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.OperationListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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( + 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("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..41df15d6ebe0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,357 @@ +# 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._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_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.storage.v2022_05_01.aio.StorageManagementClient`'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, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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.storage.v2022_05_01.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-05-01")) # 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, + account_name=account_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, + account_name=account_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 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :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.storage.v2022_05_01.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. + :type properties: ~azure.mgmt.storage.v2022_05_01.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.storage.v2022_05_01.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-05-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] + + _json = self._serialize.body(properties, 'PrivateEndpointConnection') + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.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 + + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :type private_endpoint_connection_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..35c74205aa51 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,109 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_list_by_storage_account_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list_by_storage_account( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResourceListResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + + + request = build_list_by_storage_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py new file mode 100644 index 000000000000..3c74965b65dc --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py @@ -0,0 +1,451 @@ +# 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._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`queue` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-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.StorageQueue] + + _json = self._serialize.body(queue, 'StorageQueue') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-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.StorageQueue] + + _json = self._serialize.body(queue, 'StorageQueue') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + **kwargs: Any + ) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + queue_name: str, + **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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 [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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.ListQueueResource]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListQueueResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueueResource] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + 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("ListQueueResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py new file mode 100644 index 000000000000..0221af40d5f7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py @@ -0,0 +1,263 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`queue_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListQueueServices, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListQueueServices', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] + + _json = self._serialize.body(parameters, 'QueueServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + + + @distributed_trace_async + async def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..374090c9d158 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py @@ -0,0 +1,124 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`skus` 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.StorageSkuListResult]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageSkuListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageSkuListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..5a893526bef2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py @@ -0,0 +1,1524 @@ +# 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._storage_accounts_operations import build_abort_hierarchical_namespace_migration_request_initial, build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_hierarchical_namespace_migration_request_initial, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2022_05_01.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-05-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] + + _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + + 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) + raise HttpResponseError(response=response, 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.Storage/checkNameAvailability"} # type: ignore + + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + 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-05-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.StorageAccount]] + + _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the created account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :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-05-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.StorageAccount] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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('StorageAccount', 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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace_async + async def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Default value is None. + :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + + + request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the updated account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :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-05-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.StorageAccount] + + _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.StorageAccountListResult]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.StorageAccountListResult]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :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 StorageAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace_async + async def list_keys( + self, + resource_group_name: str, + account_name: str, + expand: Optional[str] = "kerb", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. + :type regenerate_key: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :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-05-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.StorageAccountListKeysResult] + + _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAccountSasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :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-05-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.ListAccountSasResponse] + + _json = self._serialize.body(parameters, 'AccountSasParameters') + + request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListServiceSasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :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-05-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.ListServiceSasResponse] + + _json = self._serialize.body(parameters, 'ServiceSasParameters') + + request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore + + + async def _failover_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + + @distributed_trace_async + async def begin_failover( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Failover request can be triggered for a storage account in case of availability issues. The + failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS + accounts. The secondary cluster will become primary after failover. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-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] + if cont_token is None: + raw_result = await self._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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, + lro_options={'final-state-via': 'location'}, + + **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_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + request_type: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_hierarchical_namespace_migration_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + request_type=request_type, + template_url=self._hierarchical_namespace_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, 202]: + 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, {}) + + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + + @distributed_trace_async + async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + request_type: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. + :type request_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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-05-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] + if cont_token is None: + raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + 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, + lro_options={'final-state-via': 'location'}, + + **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_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_abort_hierarchical_namespace_migration_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._abort_hierarchical_namespace_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, 202]: + 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, {}) + + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + + @distributed_trace_async + async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-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] + if cont_token is None: + raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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, + lro_options={'final-state-via': 'location'}, + + **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_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + async def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + **kwargs: Any + ) -> _models.BlobRestoreStatus: + 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-05-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.BlobRestoreStatus] + + _json = self._serialize.body(parameters, 'BlobRestoreParameters') + + request = build_restore_blob_ranges_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :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-05-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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('BlobRestoreStatus', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **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_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @distributed_trace_async + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_revoke_user_delegation_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revoke_user_delegation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py new file mode 100644 index 000000000000..7cde58154a66 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py @@ -0,0 +1,441 @@ +# 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._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`table` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-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.Table] + + if parameters is not None: + _json = self._serialize.body(parameters, 'Table') + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-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.Table] + + if parameters is not None: + _json = self._serialize.body(parameters, 'Table') + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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 [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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ListTableResource]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListTableResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListTableResource] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ListTableResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py new file mode 100644 index 000000000000..3f4028731d62 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py @@ -0,0 +1,263 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`table_services` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListTableServices, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListTableServices', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] + + _json = self._serialize.body(parameters, 'TableServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TableServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + + + @distributed_trace_async + async def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TableServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..c2466ab65765 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py @@ -0,0 +1,129 @@ +# 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.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_location_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.aio.StorageManagementClient`'s + :attr:`usages` 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_location( + self, + location: str, + **kwargs: Any + ) -> AsyncIterable[_models.UsageListResult]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UsageListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.UsageListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + + error_map = { + 401: ClientAuthenticationError, 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_location_request( + subscription_id=self._config.subscription_id, + location=location, + api_version=api_version, + template_url=self.list_by_location.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_location_request( + subscription_id=self._config.subscription_id, + location=location, + 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("UsageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py new file mode 100644 index 000000000000..9743c8e2a204 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py @@ -0,0 +1,443 @@ +# 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 AccessPolicy +from ._models_py3 import AccountImmutabilityPolicyProperties +from ._models_py3 import AccountSasParameters +from ._models_py3 import ActiveDirectoryProperties +from ._models_py3 import AzureEntityResource +from ._models_py3 import AzureFilesIdentityBasedAuthentication +from ._models_py3 import BlobContainer +from ._models_py3 import BlobInventoryPolicy +from ._models_py3 import BlobInventoryPolicyDefinition +from ._models_py3 import BlobInventoryPolicyFilter +from ._models_py3 import BlobInventoryPolicyRule +from ._models_py3 import BlobInventoryPolicySchema +from ._models_py3 import BlobRestoreParameters +from ._models_py3 import BlobRestoreRange +from ._models_py3 import BlobRestoreStatus +from ._models_py3 import BlobServiceItems +from ._models_py3 import BlobServiceProperties +from ._models_py3 import ChangeFeed +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import CloudErrorBody +from ._models_py3 import CorsRule +from ._models_py3 import CorsRules +from ._models_py3 import CustomDomain +from ._models_py3 import DateAfterCreation +from ._models_py3 import DateAfterModification +from ._models_py3 import DeleteRetentionPolicy +from ._models_py3 import DeletedAccount +from ._models_py3 import DeletedAccountListResult +from ._models_py3 import DeletedShare +from ._models_py3 import Dimension +from ._models_py3 import Encryption +from ._models_py3 import EncryptionIdentity +from ._models_py3 import EncryptionScope +from ._models_py3 import EncryptionScopeKeyVaultProperties +from ._models_py3 import EncryptionScopeListResult +from ._models_py3 import EncryptionService +from ._models_py3 import EncryptionServices +from ._models_py3 import Endpoints +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import ExtendedLocation +from ._models_py3 import FileServiceItems +from ._models_py3 import FileServiceProperties +from ._models_py3 import FileShare +from ._models_py3 import FileShareItem +from ._models_py3 import FileShareItems +from ._models_py3 import GeoReplicationStats +from ._models_py3 import IPRule +from ._models_py3 import Identity +from ._models_py3 import ImmutabilityPolicy +from ._models_py3 import ImmutabilityPolicyProperties +from ._models_py3 import ImmutableStorageAccount +from ._models_py3 import ImmutableStorageWithVersioning +from ._models_py3 import KeyCreationTime +from ._models_py3 import KeyPolicy +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LastAccessTimeTrackingPolicy +from ._models_py3 import LeaseContainerRequest +from ._models_py3 import LeaseContainerResponse +from ._models_py3 import LeaseShareRequest +from ._models_py3 import LeaseShareResponse +from ._models_py3 import LegalHold +from ._models_py3 import LegalHoldProperties +from ._models_py3 import ListAccountSasResponse +from ._models_py3 import ListBlobInventoryPolicy +from ._models_py3 import ListContainerItem +from ._models_py3 import ListContainerItems +from ._models_py3 import ListQueue +from ._models_py3 import ListQueueResource +from ._models_py3 import ListQueueServices +from ._models_py3 import ListServiceSasResponse +from ._models_py3 import ListTableResource +from ._models_py3 import ListTableServices +from ._models_py3 import LocalUser +from ._models_py3 import LocalUserKeys +from ._models_py3 import LocalUserRegeneratePasswordResult +from ._models_py3 import LocalUsers +from ._models_py3 import ManagementPolicy +from ._models_py3 import ManagementPolicyAction +from ._models_py3 import ManagementPolicyBaseBlob +from ._models_py3 import ManagementPolicyDefinition +from ._models_py3 import ManagementPolicyFilter +from ._models_py3 import ManagementPolicyRule +from ._models_py3 import ManagementPolicySchema +from ._models_py3 import ManagementPolicySnapShot +from ._models_py3 import ManagementPolicyVersion +from ._models_py3 import MetricSpecification +from ._models_py3 import Multichannel +from ._models_py3 import NetworkRuleSet +from ._models_py3 import ObjectReplicationPolicies +from ._models_py3 import ObjectReplicationPolicy +from ._models_py3 import ObjectReplicationPolicyFilter +from ._models_py3 import ObjectReplicationPolicyRule +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PermissionScope +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProtectedAppendWritesHistory +from ._models_py3 import ProtocolSettings +from ._models_py3 import ProxyResource +from ._models_py3 import QueueServiceProperties +from ._models_py3 import Resource +from ._models_py3 import ResourceAccessRule +from ._models_py3 import RestorePolicyProperties +from ._models_py3 import Restriction +from ._models_py3 import RoutingPreference +from ._models_py3 import SKUCapability +from ._models_py3 import SasPolicy +from ._models_py3 import ServiceSasParameters +from ._models_py3 import ServiceSpecification +from ._models_py3 import SignedIdentifier +from ._models_py3 import Sku +from ._models_py3 import SkuInformation +from ._models_py3 import SmbSetting +from ._models_py3 import SshPublicKey +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCheckNameAvailabilityParameters +from ._models_py3 import StorageAccountCreateParameters +from ._models_py3 import StorageAccountInternetEndpoints +from ._models_py3 import StorageAccountKey +from ._models_py3 import StorageAccountListKeysResult +from ._models_py3 import StorageAccountListResult +from ._models_py3 import StorageAccountMicrosoftEndpoints +from ._models_py3 import StorageAccountRegenerateKeyParameters +from ._models_py3 import StorageAccountSkuConversionStatus +from ._models_py3 import StorageAccountUpdateParameters +from ._models_py3 import StorageQueue +from ._models_py3 import StorageSkuListResult +from ._models_py3 import SystemData +from ._models_py3 import Table +from ._models_py3 import TableAccessPolicy +from ._models_py3 import TableServiceProperties +from ._models_py3 import TableSignedIdentifier +from ._models_py3 import TagFilter +from ._models_py3 import TagProperty +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateHistoryProperty +from ._models_py3 import Usage +from ._models_py3 import UsageListResult +from ._models_py3 import UsageName +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import VirtualNetworkRule + + +from ._storage_management_client_enums import ( + AccessTier, + AccountImmutabilityPolicyState, + AccountStatus, + AccountType, + AllowedCopyScope, + AllowedMethods, + BlobInventoryPolicyName, + BlobRestoreProgressStatus, + Bypass, + CreatedByType, + DefaultAction, + DefaultSharePermission, + DirectoryServiceOptions, + DnsEndpointType, + EnabledProtocols, + EncryptionScopeSource, + EncryptionScopeState, + ExpirationAction, + ExtendedLocationTypes, + Format, + GeoReplicationStatus, + HttpProtocol, + IdentityType, + ImmutabilityPolicyState, + ImmutabilityPolicyUpdateType, + InventoryRuleType, + KeyPermission, + KeySource, + KeyType, + Kind, + LargeFileSharesState, + LeaseContainerRequestEnum, + LeaseDuration, + LeaseShareAction, + LeaseState, + LeaseStatus, + ListContainersInclude, + ManagementPolicyName, + MigrationState, + MinimumTlsVersion, + Name, + ObjectType, + Permissions, + PrivateEndpointConnectionProvisioningState, + PrivateEndpointServiceConnectionStatus, + ProvisioningState, + PublicAccess, + PublicNetworkAccess, + Reason, + ReasonCode, + RootSquashType, + RoutingChoice, + RuleType, + Schedule, + Services, + ShareAccessTier, + SignedResource, + SignedResourceTypes, + SkuConversionStatus, + SkuName, + SkuTier, + State, + StorageAccountExpand, + UsageUnit, +) +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__ = [ + 'AccessPolicy', + 'AccountImmutabilityPolicyProperties', + 'AccountSasParameters', + 'ActiveDirectoryProperties', + 'AzureEntityResource', + 'AzureFilesIdentityBasedAuthentication', + 'BlobContainer', + 'BlobInventoryPolicy', + 'BlobInventoryPolicyDefinition', + 'BlobInventoryPolicyFilter', + 'BlobInventoryPolicyRule', + 'BlobInventoryPolicySchema', + 'BlobRestoreParameters', + 'BlobRestoreRange', + 'BlobRestoreStatus', + 'BlobServiceItems', + 'BlobServiceProperties', + 'ChangeFeed', + 'CheckNameAvailabilityResult', + 'CloudErrorBody', + 'CorsRule', + 'CorsRules', + 'CustomDomain', + 'DateAfterCreation', + 'DateAfterModification', + 'DeleteRetentionPolicy', + 'DeletedAccount', + 'DeletedAccountListResult', + 'DeletedShare', + 'Dimension', + 'Encryption', + 'EncryptionIdentity', + 'EncryptionScope', + 'EncryptionScopeKeyVaultProperties', + 'EncryptionScopeListResult', + 'EncryptionService', + 'EncryptionServices', + 'Endpoints', + 'ErrorResponse', + 'ErrorResponseBody', + 'ExtendedLocation', + 'FileServiceItems', + 'FileServiceProperties', + 'FileShare', + 'FileShareItem', + 'FileShareItems', + 'GeoReplicationStats', + 'IPRule', + 'Identity', + 'ImmutabilityPolicy', + 'ImmutabilityPolicyProperties', + 'ImmutableStorageAccount', + 'ImmutableStorageWithVersioning', + 'KeyCreationTime', + 'KeyPolicy', + 'KeyVaultProperties', + 'LastAccessTimeTrackingPolicy', + 'LeaseContainerRequest', + 'LeaseContainerResponse', + 'LeaseShareRequest', + 'LeaseShareResponse', + 'LegalHold', + 'LegalHoldProperties', + 'ListAccountSasResponse', + 'ListBlobInventoryPolicy', + 'ListContainerItem', + 'ListContainerItems', + 'ListQueue', + 'ListQueueResource', + 'ListQueueServices', + 'ListServiceSasResponse', + 'ListTableResource', + 'ListTableServices', + 'LocalUser', + 'LocalUserKeys', + 'LocalUserRegeneratePasswordResult', + 'LocalUsers', + 'ManagementPolicy', + 'ManagementPolicyAction', + 'ManagementPolicyBaseBlob', + 'ManagementPolicyDefinition', + 'ManagementPolicyFilter', + 'ManagementPolicyRule', + 'ManagementPolicySchema', + 'ManagementPolicySnapShot', + 'ManagementPolicyVersion', + 'MetricSpecification', + 'Multichannel', + 'NetworkRuleSet', + 'ObjectReplicationPolicies', + 'ObjectReplicationPolicy', + 'ObjectReplicationPolicyFilter', + 'ObjectReplicationPolicyRule', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'PermissionScope', + 'PrivateEndpoint', + 'PrivateEndpointConnection', + 'PrivateEndpointConnectionListResult', + 'PrivateLinkResource', + 'PrivateLinkResourceListResult', + 'PrivateLinkServiceConnectionState', + 'ProtectedAppendWritesHistory', + 'ProtocolSettings', + 'ProxyResource', + 'QueueServiceProperties', + 'Resource', + 'ResourceAccessRule', + 'RestorePolicyProperties', + 'Restriction', + 'RoutingPreference', + 'SKUCapability', + 'SasPolicy', + 'ServiceSasParameters', + 'ServiceSpecification', + 'SignedIdentifier', + 'Sku', + 'SkuInformation', + 'SmbSetting', + 'SshPublicKey', + 'StorageAccount', + 'StorageAccountCheckNameAvailabilityParameters', + 'StorageAccountCreateParameters', + 'StorageAccountInternetEndpoints', + 'StorageAccountKey', + 'StorageAccountListKeysResult', + 'StorageAccountListResult', + 'StorageAccountMicrosoftEndpoints', + 'StorageAccountRegenerateKeyParameters', + 'StorageAccountSkuConversionStatus', + 'StorageAccountUpdateParameters', + 'StorageQueue', + 'StorageSkuListResult', + 'SystemData', + 'Table', + 'TableAccessPolicy', + 'TableServiceProperties', + 'TableSignedIdentifier', + 'TagFilter', + 'TagProperty', + 'TrackedResource', + 'UpdateHistoryProperty', + 'Usage', + 'UsageListResult', + 'UsageName', + 'UserAssignedIdentity', + 'VirtualNetworkRule', + 'AccessTier', + 'AccountImmutabilityPolicyState', + 'AccountStatus', + 'AccountType', + 'AllowedCopyScope', + 'AllowedMethods', + 'BlobInventoryPolicyName', + 'BlobRestoreProgressStatus', + 'Bypass', + 'CreatedByType', + 'DefaultAction', + 'DefaultSharePermission', + 'DirectoryServiceOptions', + 'DnsEndpointType', + 'EnabledProtocols', + 'EncryptionScopeSource', + 'EncryptionScopeState', + 'ExpirationAction', + 'ExtendedLocationTypes', + 'Format', + 'GeoReplicationStatus', + 'HttpProtocol', + 'IdentityType', + 'ImmutabilityPolicyState', + 'ImmutabilityPolicyUpdateType', + 'InventoryRuleType', + 'KeyPermission', + 'KeySource', + 'KeyType', + 'Kind', + 'LargeFileSharesState', + 'LeaseContainerRequestEnum', + 'LeaseDuration', + 'LeaseShareAction', + 'LeaseState', + 'LeaseStatus', + 'ListContainersInclude', + 'ManagementPolicyName', + 'MigrationState', + 'MinimumTlsVersion', + 'Name', + 'ObjectType', + 'Permissions', + 'PrivateEndpointConnectionProvisioningState', + 'PrivateEndpointServiceConnectionStatus', + 'ProvisioningState', + 'PublicAccess', + 'PublicNetworkAccess', + 'Reason', + 'ReasonCode', + 'RootSquashType', + 'RoutingChoice', + 'RuleType', + 'Schedule', + 'Services', + 'ShareAccessTier', + 'SignedResource', + 'SignedResourceTypes', + 'SkuConversionStatus', + 'SkuName', + 'SkuTier', + 'State', + 'StorageAccountExpand', + 'UsageUnit', +] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py new file mode 100644 index 000000000000..3b68d56ab053 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py @@ -0,0 +1,8369 @@ +# 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 datetime +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AccessPolicy(msrest.serialization.Model): + """AccessPolicy. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: List of abbreviated permissions. + :vartype permission: str + """ + + _attribute_map = { + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, + 'permission': {'key': 'permission', 'type': 'str'}, + } + + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + permission: Optional[str] = None, + **kwargs + ): + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: List of abbreviated permissions. + :paramtype permission: str + """ + super(AccessPolicy, self).__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class AccountImmutabilityPolicyProperties(msrest.serialization.Model): + """This defines account-level immutability policy properties. + + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes: bool + """ + + _validation = { + 'immutability_period_since_creation_in_days': {'maximum': 146000, 'minimum': 1}, + } + + _attribute_map = { + 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, + 'state': {'key': 'state', 'type': 'str'}, + 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, + allow_protected_append_writes: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyState + :keyword allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes: bool + """ + super(AccountImmutabilityPolicyProperties, self).__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = state + self.allow_protected_append_writes = allow_protected_append_writes + + +class AccountSasParameters(msrest.serialization.Model): + """The parameters to list SAS credentials of a storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar services: Required. The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :vartype services: str or ~azure.mgmt.storage.v2022_05_01.models.Services + :ivar resource_types: Required. The signed resource types that are accessible with the account + SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Known values are: "s", "c", "o". + :vartype resource_types: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResourceTypes + :ivar permissions: Required. The signed permissions for the account SAS. Possible values + include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". + :vartype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: Required. The time at which the shared access signature + becomes invalid. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + """ + + _validation = { + 'services': {'required': True}, + 'resource_types': {'required': True}, + 'permissions': {'required': True}, + 'shared_access_expiry_time': {'required': True}, + } + + _attribute_map = { + 'services': {'key': 'signedServices', 'type': 'str'}, + 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, + 'permissions': {'key': 'signedPermission', 'type': 'str'}, + 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, + 'protocols': {'key': 'signedProtocol', 'type': 'str'}, + 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, + 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, + 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + } + + def __init__( + self, + *, + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], + shared_access_expiry_time: datetime.datetime, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + key_to_sign: Optional[str] = None, + **kwargs + ): + """ + :keyword services: Required. The signed services accessible with the account SAS. Possible + values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :paramtype services: str or ~azure.mgmt.storage.v2022_05_01.models.Services + :keyword resource_types: Required. The signed resource types that are accessible with the + account SAS. Service (s): Access to service-level APIs; Container (c): Access to + container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table + entities, and files. Known values are: "s", "c", "o". + :paramtype resource_types: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResourceTypes + :keyword permissions: Required. The signed permissions for the account SAS. Possible values + include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process + (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: Required. The time at which the shared access signature + becomes invalid. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + """ + super(AccountSasParameters, self).__init__(**kwargs) + self.services = services + self.resource_types = resource_types + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.key_to_sign = key_to_sign + + +class ActiveDirectoryProperties(msrest.serialization.Model): + """Settings properties for Active Directory (AD). + + All required parameters must be populated in order to send to Azure. + + :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is + authoritative for. + :vartype domain_name: str + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. + :vartype net_bios_domain_name: str + :ivar forest_name: Specifies the Active Directory forest to get. + :vartype forest_name: str + :ivar domain_guid: Required. Specifies the domain GUID. + :vartype domain_guid: str + :ivar domain_sid: Specifies the security identifier (SID). + :vartype domain_sid: str + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :vartype azure_storage_sid: str + :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :vartype sam_account_name: str + :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values + are: "User", "Computer". + :vartype account_type: str or ~azure.mgmt.storage.v2022_05_01.models.AccountType + """ + + _validation = { + 'domain_name': {'required': True}, + 'domain_guid': {'required': True}, + } + + _attribute_map = { + 'domain_name': {'key': 'domainName', 'type': 'str'}, + 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, + 'forest_name': {'key': 'forestName', 'type': 'str'}, + 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, + 'domain_sid': {'key': 'domainSid', 'type': 'str'}, + 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + 'sam_account_name': {'key': 'samAccountName', 'type': 'str'}, + 'account_type': {'key': 'accountType', 'type': 'str'}, + } + + def __init__( + self, + *, + domain_name: str, + domain_guid: str, + net_bios_domain_name: Optional[str] = None, + forest_name: Optional[str] = None, + domain_sid: Optional[str] = None, + azure_storage_sid: Optional[str] = None, + sam_account_name: Optional[str] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, + **kwargs + ): + """ + :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is + authoritative for. + :paramtype domain_name: str + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. + :paramtype net_bios_domain_name: str + :keyword forest_name: Specifies the Active Directory forest to get. + :paramtype forest_name: str + :keyword domain_guid: Required. Specifies the domain GUID. + :paramtype domain_guid: str + :keyword domain_sid: Specifies the security identifier (SID). + :paramtype domain_sid: str + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :paramtype azure_storage_sid: str + :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :paramtype sam_account_name: str + :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known + values are: "User", "Computer". + :paramtype account_type: str or ~azure.mgmt.storage.v2022_05_01.models.AccountType + """ + super(ActiveDirectoryProperties, self).__init__(**kwargs) + self.domain_name = domain_name + self.net_bios_domain_name = net_bios_domain_name + self.forest_name = forest_name + self.domain_guid = domain_guid + self.domain_sid = domain_sid + self.azure_storage_sid = azure_storage_sid + self.sam_account_name = sam_account_name + self.account_type = account_type + + +class Resource(msrest.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. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + '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'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class AzureEntityResource(Resource): + """The resource model definition for an Azure Resource Manager resource with an etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AzureEntityResource, self).__init__(**kwargs) + self.etag = None + + +class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): + """Settings for Azure Files identity based authentication. + + All required parameters must be populated in order to send to Azure. + + :ivar directory_service_options: Required. Indicates the directory service used. Note that this + enum may be extended in the future. Known values are: "None", "AADDS", "AD", "AADKERB". + :vartype directory_service_options: str or + ~azure.mgmt.storage.v2022_05_01.models.DirectoryServiceOptions + :ivar active_directory_properties: Required if directoryServiceOptions are AD, optional if they + are AADKERB. + :vartype active_directory_properties: + ~azure.mgmt.storage.v2022_05_01.models.ActiveDirectoryProperties + :ivar default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareElevatedContributor". + :vartype default_share_permission: str or + ~azure.mgmt.storage.v2022_05_01.models.DefaultSharePermission + """ + + _validation = { + 'directory_service_options': {'required': True}, + } + + _attribute_map = { + 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, + 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + } + + def __init__( + self, + *, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, + **kwargs + ): + """ + :keyword directory_service_options: Required. Indicates the directory service used. Note that + this enum may be extended in the future. Known values are: "None", "AADDS", "AD", "AADKERB". + :paramtype directory_service_options: str or + ~azure.mgmt.storage.v2022_05_01.models.DirectoryServiceOptions + :keyword active_directory_properties: Required if directoryServiceOptions are AD, optional if + they are AADKERB. + :paramtype active_directory_properties: + ~azure.mgmt.storage.v2022_05_01.models.ActiveDirectoryProperties + :keyword default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareElevatedContributor". + :paramtype default_share_permission: str or + ~azure.mgmt.storage.v2022_05_01.models.DefaultSharePermission + """ + super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + self.directory_service_options = directory_service_options + self.active_directory_properties = active_directory_properties + self.default_share_permission = default_share_permission + + +class BlobContainer(AzureEntityResource): + """Properties of the blob container, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", "None". + :vartype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite", "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'version': {'readonly': True}, + 'deleted': {'readonly': True}, + 'deleted_time': {'readonly': True}, + 'remaining_retention_days': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'lease_status': {'readonly': True}, + 'lease_state': {'readonly': True}, + 'lease_duration': {'readonly': True}, + 'immutability_policy': {'readonly': True}, + 'legal_hold': {'readonly': True}, + 'has_legal_hold': {'readonly': True}, + 'has_immutability_policy': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, + 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, + 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, + 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, + 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, + 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, + 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, + 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, + 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, + 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, + 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, + 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, + 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs + ): + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super(BlobContainer, self).__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class BlobInventoryPolicy(Resource): + """The storage account blob inventory policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2022_05_01.models.SystemData + :ivar last_modified_time: Returns the last modified date and time of the blob inventory policy. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The storage account blob inventory policy object. It is composed of policy rules. + :vartype policy: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicySchema + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'last_modified_time': {'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'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + } + + def __init__( + self, + *, + policy: Optional["_models.BlobInventoryPolicySchema"] = None, + **kwargs + ): + """ + :keyword policy: The storage account blob inventory policy object. It is composed of policy + rules. + :paramtype policy: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicySchema + """ + super(BlobInventoryPolicy, self).__init__(**kwargs) + self.system_data = None + self.last_modified_time = None + self.policy = policy + + +class BlobInventoryPolicyDefinition(msrest.serialization.Model): + """An object that defines the blob inventory rule. + + All required parameters must be populated in order to send to Azure. + + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyFilter + :ivar format: Required. This is a required field, it specifies the format for the inventory + files. Known values are: "Csv", "Parquet". + :vartype format: str or ~azure.mgmt.storage.v2022_05_01.models.Format + :ivar schedule: Required. This is a required field. This field is used to schedule an inventory + formation. Known values are: "Daily", "Weekly". + :vartype schedule: str or ~azure.mgmt.storage.v2022_05_01.models.Schedule + :ivar object_type: Required. This is a required field. This field specifies the scope of the + inventory created either at the blob or container level. Known values are: "Blob", "Container". + :vartype object_type: str or ~azure.mgmt.storage.v2022_05_01.models.ObjectType + :ivar schema_fields: Required. This is a required field. This field specifies the fields and + properties of the object to be included in the inventory. The Schema field value 'Name' is + always required. The valid values for this field for the 'Blob' definition.objectType include + 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. + :vartype schema_fields: list[str] + """ + + _validation = { + 'format': {'required': True}, + 'schedule': {'required': True}, + 'object_type': {'required': True}, + 'schema_fields': {'required': True}, + } + + _attribute_map = { + 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, + 'format': {'key': 'format', 'type': 'str'}, + 'schedule': {'key': 'schedule', 'type': 'str'}, + 'object_type': {'key': 'objectType', 'type': 'str'}, + 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + } + + def __init__( + self, + *, + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], + schema_fields: List[str], + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, + **kwargs + ): + """ + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyFilter + :keyword format: Required. This is a required field, it specifies the format for the inventory + files. Known values are: "Csv", "Parquet". + :paramtype format: str or ~azure.mgmt.storage.v2022_05_01.models.Format + :keyword schedule: Required. This is a required field. This field is used to schedule an + inventory formation. Known values are: "Daily", "Weekly". + :paramtype schedule: str or ~azure.mgmt.storage.v2022_05_01.models.Schedule + :keyword object_type: Required. This is a required field. This field specifies the scope of the + inventory created either at the blob or container level. Known values are: "Blob", "Container". + :paramtype object_type: str or ~azure.mgmt.storage.v2022_05_01.models.ObjectType + :keyword schema_fields: Required. This is a required field. This field specifies the fields and + properties of the object to be included in the inventory. The Schema field value 'Name' is + always required. The valid values for this field for the 'Blob' definition.objectType include + 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. + :paramtype schema_fields: list[str] + """ + super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + self.filters = filters + self.format = format + self.schedule = schedule + self.object_type = object_type + self.schema_fields = schema_fields + + +class BlobInventoryPolicyFilter(msrest.serialization.Model): + """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. + + :ivar prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :vartype prefix_match: list[str] + :ivar exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from the + inventory. + :vartype exclude_prefix: list[str] + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :vartype blob_types: list[str] + :ivar include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :vartype include_blob_versions: bool + :ivar include_snapshots: Includes blob snapshots in blob inventory when value is set to true. + The definition.schemaFields value 'Snapshot' is required if this property is set to true, else + it must be excluded. + :vartype include_snapshots: bool + :ivar include_deleted: For 'Container' definition.objectType the definition.schemaFields must + include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :vartype include_deleted: bool + """ + + _attribute_map = { + 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, + 'exclude_prefix': {'key': 'excludePrefix', 'type': '[str]'}, + 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, + 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, + 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + 'include_deleted': {'key': 'includeDeleted', 'type': 'bool'}, + } + + def __init__( + self, + *, + prefix_match: Optional[List[str]] = None, + exclude_prefix: Optional[List[str]] = None, + blob_types: Optional[List[str]] = None, + include_blob_versions: Optional[bool] = None, + include_snapshots: Optional[bool] = None, + include_deleted: Optional[bool] = None, + **kwargs + ): + """ + :keyword prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :paramtype prefix_match: list[str] + :keyword exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from + the inventory. + :paramtype exclude_prefix: list[str] + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :paramtype blob_types: list[str] + :keyword include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :paramtype include_blob_versions: bool + :keyword include_snapshots: Includes blob snapshots in blob inventory when value is set to + true. The definition.schemaFields value 'Snapshot' is required if this property is set to true, + else it must be excluded. + :paramtype include_snapshots: bool + :keyword include_deleted: For 'Container' definition.objectType the definition.schemaFields + must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :paramtype include_deleted: bool + """ + super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + self.prefix_match = prefix_match + self.exclude_prefix = exclude_prefix + self.blob_types = blob_types + self.include_blob_versions = include_blob_versions + self.include_snapshots = include_snapshots + self.include_deleted = include_deleted + + +class BlobInventoryPolicyRule(msrest.serialization.Model): + """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Required. Rule is enabled when set to true. + :vartype enabled: bool + :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule + name is case-sensitive. It must be unique within a policy. + :vartype name: str + :ivar destination: Required. Container name where blob inventory files are stored. Must be + pre-created. + :vartype destination: str + :ivar definition: Required. An object that defines the blob inventory policy rule. + :vartype definition: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyDefinition + """ + + _validation = { + 'enabled': {'required': True}, + 'name': {'required': True}, + 'destination': {'required': True}, + 'definition': {'required': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'destination': {'key': 'destination', 'type': 'str'}, + 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + } + + def __init__( + self, + *, + enabled: bool, + name: str, + destination: str, + definition: "_models.BlobInventoryPolicyDefinition", + **kwargs + ): + """ + :keyword enabled: Required. Rule is enabled when set to true. + :paramtype enabled: bool + :keyword name: Required. A rule name can contain any combination of alpha numeric characters. + Rule name is case-sensitive. It must be unique within a policy. + :paramtype name: str + :keyword destination: Required. Container name where blob inventory files are stored. Must be + pre-created. + :paramtype destination: str + :keyword definition: Required. An object that defines the blob inventory policy rule. + :paramtype definition: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyDefinition + """ + super(BlobInventoryPolicyRule, self).__init__(**kwargs) + self.enabled = enabled + self.name = name + self.destination = destination + self.definition = definition + + +class BlobInventoryPolicySchema(msrest.serialization.Model): + """The storage account blob inventory policy rules. + + 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 enabled: Required. Policy is enabled if set to true. + :vartype enabled: bool + :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required + destination container name must be specified at the rule level 'policy.rule.destination'. + :vartype destination: str + :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.InventoryRuleType + :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied + when it is enabled. + :vartype rules: list[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyRule] + """ + + _validation = { + 'enabled': {'required': True}, + 'destination': {'readonly': True}, + 'type': {'required': True}, + 'rules': {'required': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'destination': {'key': 'destination', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + } + + def __init__( + self, + *, + enabled: bool, + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], + **kwargs + ): + """ + :keyword enabled: Required. Policy is enabled if set to true. + :paramtype enabled: bool + :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.InventoryRuleType + :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied + when it is enabled. + :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyRule] + """ + super(BlobInventoryPolicySchema, self).__init__(**kwargs) + self.enabled = enabled + self.destination = None + self.type = type + self.rules = rules + + +class BlobRestoreParameters(msrest.serialization.Model): + """Blob restore parameters. + + All required parameters must be populated in order to send to Azure. + + :ivar time_to_restore: Required. Restore blob to the specified time. + :vartype time_to_restore: ~datetime.datetime + :ivar blob_ranges: Required. Blob ranges to restore. + :vartype blob_ranges: list[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreRange] + """ + + _validation = { + 'time_to_restore': {'required': True}, + 'blob_ranges': {'required': True}, + } + + _attribute_map = { + 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, + 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + } + + def __init__( + self, + *, + time_to_restore: datetime.datetime, + blob_ranges: List["_models.BlobRestoreRange"], + **kwargs + ): + """ + :keyword time_to_restore: Required. Restore blob to the specified time. + :paramtype time_to_restore: ~datetime.datetime + :keyword blob_ranges: Required. Blob ranges to restore. + :paramtype blob_ranges: list[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreRange] + """ + super(BlobRestoreParameters, self).__init__(**kwargs) + self.time_to_restore = time_to_restore + self.blob_ranges = blob_ranges + + +class BlobRestoreRange(msrest.serialization.Model): + """Blob range. + + All required parameters must be populated in order to send to Azure. + + :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :vartype start_range: str + :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :vartype end_range: str + """ + + _validation = { + 'start_range': {'required': True}, + 'end_range': {'required': True}, + } + + _attribute_map = { + 'start_range': {'key': 'startRange', 'type': 'str'}, + 'end_range': {'key': 'endRange', 'type': 'str'}, + } + + def __init__( + self, + *, + start_range: str, + end_range: str, + **kwargs + ): + """ + :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :paramtype start_range: str + :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :paramtype end_range: str + """ + super(BlobRestoreRange, self).__init__(**kwargs) + self.start_range = start_range + self.end_range = end_range + + +class BlobRestoreStatus(msrest.serialization.Model): + """Blob restore status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates + that blob restore is ongoing. - Complete: Indicates that blob restore has been completed + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", "Failed". + :vartype status: str or ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreProgressStatus + :ivar failure_reason: Failure reason when blob restore is failed. + :vartype failure_reason: str + :ivar restore_id: Id for tracking blob restore request. + :vartype restore_id: str + :ivar parameters: Blob restore request parameters. + :vartype parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters + """ + + _validation = { + 'status': {'readonly': True}, + 'failure_reason': {'readonly': True}, + 'restore_id': {'readonly': True}, + 'parameters': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'failure_reason': {'key': 'failureReason', 'type': 'str'}, + 'restore_id': {'key': 'restoreId', 'type': 'str'}, + 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(BlobRestoreStatus, self).__init__(**kwargs) + self.status = None + self.failure_reason = None + self.restore_id = None + self.parameters = None + + +class BlobServiceItems(msrest.serialization.Model): + """BlobServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob services returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(BlobServiceItems, self).__init__(**kwargs) + self.value = None + + +class BlobServiceProperties(Resource): + """The properties of a storage account’s Blob service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :ivar cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :vartype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + :ivar default_service_version: DefaultServiceVersion indicates the default version to use for + requests to the Blob service if an incoming request’s version is not specified. Possible values + include version 2008-10-27 and all more recent versions. + :vartype default_service_version: str + :ivar delete_retention_policy: The blob service properties for blob soft delete. + :vartype delete_retention_policy: ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :ivar is_versioning_enabled: Versioning is enabled if set to true. + :vartype is_versioning_enabled: bool + :ivar automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled property. + :vartype automatic_snapshot_policy_enabled: bool + :ivar change_feed: The blob service properties for change feed events. + :vartype change_feed: ~azure.mgmt.storage.v2022_05_01.models.ChangeFeed + :ivar restore_policy: The blob service properties for blob restore policy. + :vartype restore_policy: ~azure.mgmt.storage.v2022_05_01.models.RestorePolicyProperties + :ivar container_delete_retention_policy: The blob service properties for container soft delete. + :vartype container_delete_retention_policy: + ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :ivar last_access_time_tracking_policy: The blob service property to configure last access time + based tracking policy. + :vartype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2022_05_01.models.LastAccessTimeTrackingPolicy + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'sku': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, + 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, + 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, + 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, + 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, + 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + default_service_version: Optional[str] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + is_versioning_enabled: Optional[bool] = None, + automatic_snapshot_policy_enabled: Optional[bool] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + :keyword default_service_version: DefaultServiceVersion indicates the default version to use + for requests to the Blob service if an incoming request’s version is not specified. Possible + values include version 2008-10-27 and all more recent versions. + :paramtype default_service_version: str + :keyword delete_retention_policy: The blob service properties for blob soft delete. + :paramtype delete_retention_policy: + ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :keyword is_versioning_enabled: Versioning is enabled if set to true. + :paramtype is_versioning_enabled: bool + :keyword automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled + property. + :paramtype automatic_snapshot_policy_enabled: bool + :keyword change_feed: The blob service properties for change feed events. + :paramtype change_feed: ~azure.mgmt.storage.v2022_05_01.models.ChangeFeed + :keyword restore_policy: The blob service properties for blob restore policy. + :paramtype restore_policy: ~azure.mgmt.storage.v2022_05_01.models.RestorePolicyProperties + :keyword container_delete_retention_policy: The blob service properties for container soft + delete. + :paramtype container_delete_retention_policy: + ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :keyword last_access_time_tracking_policy: The blob service property to configure last access + time based tracking policy. + :paramtype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2022_05_01.models.LastAccessTimeTrackingPolicy + """ + super(BlobServiceProperties, self).__init__(**kwargs) + self.sku = None + self.cors = cors + self.default_service_version = default_service_version + self.delete_retention_policy = delete_retention_policy + self.is_versioning_enabled = is_versioning_enabled + self.automatic_snapshot_policy_enabled = automatic_snapshot_policy_enabled + self.change_feed = change_feed + self.restore_policy = restore_policy + self.container_delete_retention_policy = container_delete_retention_policy + self.last_access_time_tracking_policy = last_access_time_tracking_policy + + +class ChangeFeed(msrest.serialization.Model): + """The blob service properties for change feed events. + + :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. + :vartype enabled: bool + :ivar retention_in_days: Indicates the duration of changeFeed retention in days. Minimum value + is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :vartype retention_in_days: int + """ + + _validation = { + 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + retention_in_days: Optional[int] = None, + **kwargs + ): + """ + :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. + :paramtype enabled: bool + :keyword retention_in_days: Indicates the duration of changeFeed retention in days. Minimum + value is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :paramtype retention_in_days: int + """ + super(ChangeFeed, self).__init__(**kwargs) + self.enabled = enabled + self.retention_in_days = retention_in_days + + +class CheckNameAvailabilityResult(msrest.serialization.Model): + """The CheckNameAvailability operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: Gets a boolean value that indicates whether the name is available for you + to use. If true, the name is available. If false, the name has already been taken or is invalid + and cannot be used. + :vartype name_available: bool + :ivar reason: Gets the reason that a storage account name could not be used. The Reason element + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.storage.v2022_05_01.models.Reason + :ivar message: Gets an error message explaining the Reason value in more detail. + :vartype message: str + """ + + _validation = { + 'name_available': {'readonly': True}, + 'reason': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(CheckNameAvailabilityResult, self).__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = None + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Storage service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.storage.v2022_05_01.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.storage.v2022_05_01.models.CloudErrorBody] + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class CorsRule(msrest.serialization.Model): + """Specifies a CORS rule for the Blob service. + + All required parameters must be populated in order to send to Azure. + + :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin + domains that will be allowed via CORS, or "*" to allow all domains. + :vartype allowed_origins: list[str] + :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP + methods that are allowed to be executed by the origin. + :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2022_05_01.models.AllowedMethods] + :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of + seconds that the client/browser should cache a preflight response. + :vartype max_age_in_seconds: int + :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response + headers to expose to CORS clients. + :vartype exposed_headers: list[str] + :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers + allowed to be part of the cross-origin request. + :vartype allowed_headers: list[str] + """ + + _validation = { + 'allowed_origins': {'required': True}, + 'allowed_methods': {'required': True}, + 'max_age_in_seconds': {'required': True}, + 'exposed_headers': {'required': True}, + 'allowed_headers': {'required': True}, + } + + _attribute_map = { + 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, + 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, + 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, + 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, + 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + } + + def __init__( + self, + *, + allowed_origins: List[str], + allowed_methods: List[Union[str, "_models.AllowedMethods"]], + max_age_in_seconds: int, + exposed_headers: List[str], + allowed_headers: List[str], + **kwargs + ): + """ + :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin + domains that will be allowed via CORS, or "*" to allow all domains. + :paramtype allowed_origins: list[str] + :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP + methods that are allowed to be executed by the origin. + :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2022_05_01.models.AllowedMethods] + :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of + seconds that the client/browser should cache a preflight response. + :paramtype max_age_in_seconds: int + :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response + headers to expose to CORS clients. + :paramtype exposed_headers: list[str] + :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers + allowed to be part of the cross-origin request. + :paramtype allowed_headers: list[str] + """ + super(CorsRule, self).__init__(**kwargs) + self.allowed_origins = allowed_origins + self.allowed_methods = allowed_methods + self.max_age_in_seconds = max_age_in_seconds + self.exposed_headers = exposed_headers + self.allowed_headers = allowed_headers + + +class CorsRules(msrest.serialization.Model): + """Sets the CORS rules. You can include up to five CorsRule elements in the request. + + :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the + request. + :vartype cors_rules: list[~azure.mgmt.storage.v2022_05_01.models.CorsRule] + """ + + _attribute_map = { + 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + } + + def __init__( + self, + *, + cors_rules: Optional[List["_models.CorsRule"]] = None, + **kwargs + ): + """ + :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in + the request. + :paramtype cors_rules: list[~azure.mgmt.storage.v2022_05_01.models.CorsRule] + """ + super(CorsRules, self).__init__(**kwargs) + self.cors_rules = cors_rules + + +class CustomDomain(msrest.serialization.Model): + """The custom domain assigned to this storage account. This can be set via Update. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name + is the CNAME source. + :vartype name: str + :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :vartype use_sub_domain_name: bool + """ + + _validation = { + 'name': {'required': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + } + + def __init__( + self, + *, + name: str, + use_sub_domain_name: Optional[bool] = None, + **kwargs + ): + """ + :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. + Name is the CNAME source. + :paramtype name: str + :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :paramtype use_sub_domain_name: bool + """ + super(CustomDomain, self).__init__(**kwargs) + self.name = name + self.use_sub_domain_name = use_sub_domain_name + + +class DateAfterCreation(msrest.serialization.Model): + """Object to define snapshot and version action conditions. + + All required parameters must be populated in order to send to Azure. + + :ivar days_after_creation_greater_than: Required. Value indicating the age in days after + creation. + :vartype days_after_creation_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + """ + + _validation = { + 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, + } + + _attribute_map = { + 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, + } + + def __init__( + self, + *, + days_after_creation_greater_than: float, + days_after_last_tier_change_greater_than: Optional[float] = None, + **kwargs + ): + """ + :keyword days_after_creation_greater_than: Required. Value indicating the age in days after + creation. + :paramtype days_after_creation_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + """ + super(DateAfterCreation, self).__init__(**kwargs) + self.days_after_creation_greater_than = days_after_creation_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + + +class DateAfterModification(msrest.serialization.Model): + """Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. + + :ivar days_after_modification_greater_than: Value indicating the age in days after last + modification. + :vartype days_after_modification_greater_than: float + :ivar days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :vartype days_after_last_access_time_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + :ivar days_after_creation_greater_than: Value indicating the age in days after blob creation. + :vartype days_after_creation_greater_than: float + """ + + _validation = { + 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, + 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, + 'days_after_creation_greater_than': {'minimum': 0, 'multiple': 1}, + } + + _attribute_map = { + 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, + 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, + 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + } + + def __init__( + self, + *, + days_after_modification_greater_than: Optional[float] = None, + days_after_last_access_time_greater_than: Optional[float] = None, + days_after_last_tier_change_greater_than: Optional[float] = None, + days_after_creation_greater_than: Optional[float] = None, + **kwargs + ): + """ + :keyword days_after_modification_greater_than: Value indicating the age in days after last + modification. + :paramtype days_after_modification_greater_than: float + :keyword days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :paramtype days_after_last_access_time_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + :keyword days_after_creation_greater_than: Value indicating the age in days after blob + creation. + :paramtype days_after_creation_greater_than: float + """ + super(DateAfterModification, self).__init__(**kwargs) + self.days_after_modification_greater_than = days_after_modification_greater_than + self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + self.days_after_creation_greater_than = days_after_creation_greater_than + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + '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'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class DeletedAccount(ProxyResource): + """Deleted storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar storage_account_resource_id: Full resource id of the original storage account. + :vartype storage_account_resource_id: str + :ivar location: Location of the deleted account. + :vartype location: str + :ivar restore_reference: Can be used to attempt recovering this deleted account via + PutStorageAccount API. + :vartype restore_reference: str + :ivar creation_time: Creation time of the deleted account. + :vartype creation_time: str + :ivar deletion_time: Deletion time of the deleted account. + :vartype deletion_time: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'storage_account_resource_id': {'readonly': True}, + 'location': {'readonly': True}, + 'restore_reference': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'deletion_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, + 'location': {'key': 'properties.location', 'type': 'str'}, + 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, + 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(DeletedAccount, self).__init__(**kwargs) + self.storage_account_resource_id = None + self.location = None + self.restore_reference = None + self.creation_time = None + self.deletion_time = None + + +class DeletedAccountListResult(msrest.serialization.Model): + """The response from the List Deleted Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of deleted accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.DeletedAccount] + :ivar next_link: Request URL that can be used to query next page of deleted accounts. Returned + when total number of requested deleted accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[DeletedAccount]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(DeletedAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class DeletedShare(msrest.serialization.Model): + """The deleted share to be restored. + + All required parameters must be populated in order to send to Azure. + + :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will + be restored. + :vartype deleted_share_name: str + :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that + will be restored. + :vartype deleted_share_version: str + """ + + _validation = { + 'deleted_share_name': {'required': True}, + 'deleted_share_version': {'required': True}, + } + + _attribute_map = { + 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, + 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + deleted_share_name: str, + deleted_share_version: str, + **kwargs + ): + """ + :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that + will be restored. + :paramtype deleted_share_name: str + :keyword deleted_share_version: Required. Required. Identify the version of the deleted share + that will be restored. + :paramtype deleted_share_version: str + """ + super(DeletedShare, self).__init__(**kwargs) + self.deleted_share_name = deleted_share_name + self.deleted_share_version = deleted_share_version + + +class DeleteRetentionPolicy(msrest.serialization.Model): + """The service properties for soft delete. + + :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. + :vartype enabled: bool + :ivar days: Indicates the number of days that the deleted item should be retained. The minimum + specified value can be 1 and the maximum value can be 365. + :vartype days: int + :ivar allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :vartype allow_permanent_delete: bool + """ + + _validation = { + 'days': {'maximum': 365, 'minimum': 1}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'days': {'key': 'days', 'type': 'int'}, + 'allow_permanent_delete': {'key': 'allowPermanentDelete', 'type': 'bool'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + days: Optional[int] = None, + allow_permanent_delete: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. + :paramtype enabled: bool + :keyword days: Indicates the number of days that the deleted item should be retained. The + minimum specified value can be 1 and the maximum value can be 365. + :paramtype days: int + :keyword allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :paramtype allow_permanent_delete: bool + """ + super(DeleteRetentionPolicy, self).__init__(**kwargs) + self.enabled = enabled + self.days = days + self.allow_permanent_delete = allow_permanent_delete + + +class Dimension(msrest.serialization.Model): + """Dimension of blobs, possibly be blob type or access tier. + + :ivar name: Display name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Display name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + """ + super(Dimension, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + + +class Encryption(msrest.serialization.Model): + """The encryption settings on the storage account. + + :ivar services: List of services which support encryption. + :vartype services: ~azure.mgmt.storage.v2022_05_01.models.EncryptionServices + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", + "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :vartype key_source: str or ~azure.mgmt.storage.v2022_05_01.models.KeySource + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + :ivar key_vault_properties: Properties provided by key vault. + :vartype key_vault_properties: ~azure.mgmt.storage.v2022_05_01.models.KeyVaultProperties + :ivar encryption_identity: The identity to be used with service-side encryption at rest. + :vartype encryption_identity: ~azure.mgmt.storage.v2022_05_01.models.EncryptionIdentity + """ + + _attribute_map = { + 'services': {'key': 'services', 'type': 'EncryptionServices'}, + 'key_source': {'key': 'keySource', 'type': 'str'}, + 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, + 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + } + + def __init__( + self, + *, + services: Optional["_models.EncryptionServices"] = None, + key_source: Optional[Union[str, "_models.KeySource"]] = "Microsoft.Storage", + require_infrastructure_encryption: Optional[bool] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, + **kwargs + ): + """ + :keyword services: List of services which support encryption. + :paramtype services: ~azure.mgmt.storage.v2022_05_01.models.EncryptionServices + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", + "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :paramtype key_source: str or ~azure.mgmt.storage.v2022_05_01.models.KeySource + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + :keyword key_vault_properties: Properties provided by key vault. + :paramtype key_vault_properties: ~azure.mgmt.storage.v2022_05_01.models.KeyVaultProperties + :keyword encryption_identity: The identity to be used with service-side encryption at rest. + :paramtype encryption_identity: ~azure.mgmt.storage.v2022_05_01.models.EncryptionIdentity + """ + super(Encryption, self).__init__(**kwargs) + self.services = services + self.key_source = key_source + self.require_infrastructure_encryption = require_infrastructure_encryption + self.key_vault_properties = key_vault_properties + self.encryption_identity = encryption_identity + + +class EncryptionIdentity(msrest.serialization.Model): + """Encryption identity for the storage account. + + :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be + associated with server-side encryption on the storage account. + :vartype encryption_user_assigned_identity: str + :ivar encryption_federated_identity_client_id: ClientId of the multi-tenant application to be + used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :vartype encryption_federated_identity_client_id: str + """ + + _attribute_map = { + 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + 'encryption_federated_identity_client_id': {'key': 'federatedIdentityClientId', 'type': 'str'}, + } + + def __init__( + self, + *, + encryption_user_assigned_identity: Optional[str] = None, + encryption_federated_identity_client_id: Optional[str] = None, + **kwargs + ): + """ + :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to + be associated with server-side encryption on the storage account. + :paramtype encryption_user_assigned_identity: str + :keyword encryption_federated_identity_client_id: ClientId of the multi-tenant application to + be used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :paramtype encryption_federated_identity_client_id: str + """ + super(EncryptionIdentity, self).__init__(**kwargs) + self.encryption_user_assigned_identity = encryption_user_assigned_identity + self.encryption_federated_identity_client_id = encryption_federated_identity_client_id + + +class EncryptionScope(Resource): + """The Encryption Scope resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + "Microsoft.KeyVault". + :vartype source: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeSource + :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, + Disabled. Known values are: "Enabled", "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeState + :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets the last modification date and time of the encryption scope in + UTC. + :vartype last_modified_time: ~datetime.datetime + :ivar key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :vartype key_vault_properties: + ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeKeyVaultProperties + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, + 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + } + + def __init__( + self, + *, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, + require_infrastructure_encryption: Optional[bool] = None, + **kwargs + ): + """ + :keyword source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + "Microsoft.KeyVault". + :paramtype source: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeSource + :keyword state: The state of the encryption scope. Possible values (case-insensitive): + Enabled, Disabled. Known values are: "Enabled", "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeState + :keyword key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :paramtype key_vault_properties: + ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeKeyVaultProperties + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + """ + super(EncryptionScope, self).__init__(**kwargs) + self.source = source + self.state = state + self.creation_time = None + self.last_modified_time = None + self.key_vault_properties = key_vault_properties + self.require_infrastructure_encryption = require_infrastructure_encryption + + +class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): + """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_uri: The object identifier for a key vault key object. When applied, the encryption + scope will use the key referenced by the identifier to enable customer-managed key support on + this encryption scope. + :vartype key_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + """ + + _validation = { + 'current_versioned_key_identifier': {'readonly': True}, + 'last_key_rotation_timestamp': {'readonly': True}, + } + + _attribute_map = { + 'key_uri': {'key': 'keyUri', 'type': 'str'}, + 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, + 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + key_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword key_uri: The object identifier for a key vault key object. When applied, the + encryption scope will use the key referenced by the identifier to enable customer-managed key + support on this encryption scope. + :paramtype key_uri: str + """ + super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + self.key_uri = key_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + + +class EncryptionScopeListResult(msrest.serialization.Model): + """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of encryption scopes requested. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.EncryptionScope] + :ivar next_link: Request URL that can be used to query next page of encryption scopes. Returned + when total number of requested encryption scopes exceeds the maximum page size. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EncryptionScope]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(EncryptionScopeListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class EncryptionService(msrest.serialization.Model): + """A service that allows server-side encryption to be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :vartype enabled: bool + :ivar last_enabled_time: Gets a rough estimate of the date/time when the encryption was last + enabled by the user. Data is encrypted at rest by default today and cannot be disabled. + :vartype last_enabled_time: ~datetime.datetime + :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type + implies that an account-scoped encryption key will be used. 'Service' key type implies that a + default service key is used. Known values are: "Service", "Account". + :vartype key_type: str or ~azure.mgmt.storage.v2022_05_01.models.KeyType + """ + + _validation = { + 'last_enabled_time': {'readonly': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + 'key_type': {'key': 'keyType', 'type': 'str'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + key_type: Optional[Union[str, "_models.KeyType"]] = None, + **kwargs + ): + """ + :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :paramtype enabled: bool + :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key + type implies that an account-scoped encryption key will be used. 'Service' key type implies + that a default service key is used. Known values are: "Service", "Account". + :paramtype key_type: str or ~azure.mgmt.storage.v2022_05_01.models.KeyType + """ + super(EncryptionService, self).__init__(**kwargs) + self.enabled = enabled + self.last_enabled_time = None + self.key_type = key_type + + +class EncryptionServices(msrest.serialization.Model): + """A list of services that support encryption. + + :ivar blob: The encryption function of the blob storage service. + :vartype blob: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :ivar file: The encryption function of the file storage service. + :vartype file: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :ivar table: The encryption function of the table storage service. + :vartype table: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :ivar queue: The encryption function of the queue storage service. + :vartype queue: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + """ + + _attribute_map = { + 'blob': {'key': 'blob', 'type': 'EncryptionService'}, + 'file': {'key': 'file', 'type': 'EncryptionService'}, + 'table': {'key': 'table', 'type': 'EncryptionService'}, + 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + } + + def __init__( + self, + *, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, + **kwargs + ): + """ + :keyword blob: The encryption function of the blob storage service. + :paramtype blob: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :keyword file: The encryption function of the file storage service. + :paramtype file: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :keyword table: The encryption function of the table storage service. + :paramtype table: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + :keyword queue: The encryption function of the queue storage service. + :paramtype queue: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService + """ + super(EncryptionServices, self).__init__(**kwargs) + self.blob = blob + self.file = file + self.table = table + self.queue = queue + + +class Endpoints(msrest.serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + :ivar microsoft_endpoints: Gets the microsoft routing storage endpoints. + :vartype microsoft_endpoints: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountMicrosoftEndpoints + :ivar internet_endpoints: Gets the internet routing storage endpoints. + :vartype internet_endpoints: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountInternetEndpoints + """ + + _validation = { + 'blob': {'readonly': True}, + 'queue': {'readonly': True}, + 'table': {'readonly': True}, + 'file': {'readonly': True}, + 'web': {'readonly': True}, + 'dfs': {'readonly': True}, + } + + _attribute_map = { + 'blob': {'key': 'blob', 'type': 'str'}, + 'queue': {'key': 'queue', 'type': 'str'}, + 'table': {'key': 'table', 'type': 'str'}, + 'file': {'key': 'file', 'type': 'str'}, + 'web': {'key': 'web', 'type': 'str'}, + 'dfs': {'key': 'dfs', 'type': 'str'}, + 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, + 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + } + + def __init__( + self, + *, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, + **kwargs + ): + """ + :keyword microsoft_endpoints: Gets the microsoft routing storage endpoints. + :paramtype microsoft_endpoints: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountMicrosoftEndpoints + :keyword internet_endpoints: Gets the internet routing storage endpoints. + :paramtype internet_endpoints: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountInternetEndpoints + """ + super(Endpoints, self).__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + self.microsoft_endpoints = microsoft_endpoints + self.internet_endpoints = internet_endpoints + + +class ErrorResponse(msrest.serialization.Model): + """An error response from the storage resource provider. + + :ivar error: Azure Storage Resource Provider error response body. + :vartype error: ~azure.mgmt.storage.v2022_05_01.models.ErrorResponseBody + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorResponseBody"] = None, + **kwargs + ): + """ + :keyword error: Azure Storage Resource Provider error response body. + :paramtype error: ~azure.mgmt.storage.v2022_05_01.models.ErrorResponseBody + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ErrorResponseBody(msrest.serialization.Model): + """Error response body contract. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super(ErrorResponseBody, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ExtendedLocation(msrest.serialization.Model): + """The complex type of the extended location. + + :ivar name: The name of the extended location. + :vartype name: str + :ivar type: The type of the extended location. Known values are: "EdgeZone". + :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocationTypes + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + **kwargs + ): + """ + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. Known values are: "EdgeZone". + :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocationTypes + """ + super(ExtendedLocation, self).__init__(**kwargs) + self.name = name + self.type = type + + +class FileServiceItems(msrest.serialization.Model): + """FileServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file services returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(FileServiceItems, self).__init__(**kwargs) + self.value = None + + +class FileServiceProperties(Resource): + """The properties of File services in storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :ivar cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :vartype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + :ivar share_delete_retention_policy: The file service properties for share soft delete. + :vartype share_delete_retention_policy: + ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :ivar protocol_settings: Protocol settings for file service. + :vartype protocol_settings: ~azure.mgmt.storage.v2022_05_01.models.ProtocolSettings + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'sku': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + :keyword share_delete_retention_policy: The file service properties for share soft delete. + :paramtype share_delete_retention_policy: + ~azure.mgmt.storage.v2022_05_01.models.DeleteRetentionPolicy + :keyword protocol_settings: Protocol settings for file service. + :paramtype protocol_settings: ~azure.mgmt.storage.v2022_05_01.models.ProtocolSettings + """ + super(FileServiceProperties, self).__init__(**kwargs) + self.sku = None + self.cors = cors + self.share_delete_retention_policy = share_delete_retention_policy + self.protocol_settings = protocol_settings + + +class FileShare(AzureEntityResource): + """Properties of the file share, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB", "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: long + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite", "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'share_quota': {'maximum': 102400, 'minimum': 1}, + 'version': {'readonly': True}, + 'deleted': {'readonly': True}, + 'deleted_time': {'readonly': True}, + 'remaining_retention_days': {'readonly': True}, + 'access_tier_change_time': {'readonly': True}, + 'access_tier_status': {'readonly': True}, + 'share_usage_bytes': {'readonly': True}, + 'lease_status': {'readonly': True}, + 'lease_state': {'readonly': True}, + 'lease_duration': {'readonly': True}, + 'snapshot_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, + 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, + 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, + 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, + 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, + 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, + 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, + 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, + 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, + 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, + 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, + 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, + 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB", "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] + """ + super(FileShare, self).__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItem(AzureEntityResource): + """The file share properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB", "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: long + :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite", "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'share_quota': {'maximum': 102400, 'minimum': 1}, + 'version': {'readonly': True}, + 'deleted': {'readonly': True}, + 'deleted_time': {'readonly': True}, + 'remaining_retention_days': {'readonly': True}, + 'access_tier_change_time': {'readonly': True}, + 'access_tier_status': {'readonly': True}, + 'share_usage_bytes': {'readonly': True}, + 'lease_status': {'readonly': True}, + 'lease_state': {'readonly': True}, + 'lease_duration': {'readonly': True}, + 'snapshot_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, + 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, + 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, + 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, + 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, + 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, + 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, + 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, + 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, + 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, + 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, + 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, + 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB", "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] + """ + super(FileShareItem, self).__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItems(msrest.serialization.Model): + """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file shares returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.FileShareItem] + :ivar next_link: Request URL that can be used to query next page of shares. Returned when total + number of requested shares exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FileShareItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(FileShareItems, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class GeoReplicationStats(msrest.serialization.Model): + """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the secondary location. Possible values are: - Live: Indicates that + the secondary location is active and operational. - Bootstrap: Indicates initial + synchronization from the primary location to the secondary location is in progress.This + typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary + location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + :vartype status: str or ~azure.mgmt.storage.v2022_05_01.models.GeoReplicationStatus + :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to + be available for read operations. Primary writes following this point in time may or may not be + available for reads. Element may be default value if value of LastSyncTime is not available, + this can happen if secondary is offline or we are in bootstrap. + :vartype last_sync_time: ~datetime.datetime + :ivar can_failover: A boolean flag which indicates whether or not account failover is supported + for the account. + :vartype can_failover: bool + """ + + _validation = { + 'status': {'readonly': True}, + 'last_sync_time': {'readonly': True}, + 'can_failover': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, + 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(GeoReplicationStats, self).__init__(**kwargs) + self.status = None + self.last_sync_time = None + self.can_failover = None + + +class Identity(msrest.serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.IdentityType + :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of + User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2022_05_01.models.UserAssignedIdentity] + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'type': {'required': 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}'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", + "UserAssigned", "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.IdentityType + :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set + of User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2022_05_01.models.UserAssignedIdentity] + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ImmutabilityPolicy(AzureEntityResource): + """The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked", "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super(ImmutabilityPolicy, self).__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutabilityPolicyProperties(msrest.serialization.Model): + """The properties of an ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar etag: ImmutabilityPolicy Etag. + :vartype etag: str + :ivar update_history: The ImmutabilityPolicy update history of the blob container. + :vartype update_history: list[~azure.mgmt.storage.v2022_05_01.models.UpdateHistoryProperty] + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked", "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + 'etag': {'readonly': True}, + 'update_history': {'readonly': True}, + 'state': {'readonly': True}, + } + + _attribute_map = { + 'etag': {'key': 'etag', 'type': 'str'}, + 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, + 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + self.etag = None + self.update_history = None + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutableStorageAccount(msrest.serialization.Model): + """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. + + :ivar enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :vartype enabled: bool + :ivar immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyProperties + """ + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'immutability_policy': {'key': 'immutabilityPolicy', 'type': 'AccountImmutabilityPolicyProperties'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, + **kwargs + ): + """ + :keyword enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :paramtype enabled: bool + :keyword immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :paramtype immutability_policy: + ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyProperties + """ + super(ImmutableStorageAccount, self).__init__(**kwargs) + self.enabled = enabled + self.immutability_policy = immutability_policy + + +class ImmutableStorageWithVersioning(msrest.serialization.Model): + """Object level immutability properties of the container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :vartype enabled: bool + :ivar time_stamp: Returns the date and time the object level immutability was enabled. + :vartype time_stamp: ~datetime.datetime + :ivar migration_state: This property denotes the container level immutability to object level + immutability migration state. Known values are: "InProgress", "Completed". + :vartype migration_state: str or ~azure.mgmt.storage.v2022_05_01.models.MigrationState + """ + + _validation = { + 'time_stamp': {'readonly': True}, + 'migration_state': {'readonly': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, + 'migration_state': {'key': 'migrationState', 'type': 'str'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :paramtype enabled: bool + """ + super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + self.enabled = enabled + self.time_stamp = None + self.migration_state = None + + +class IPRule(msrest.serialization.Model): + """IP rule with specific IP or IP range in CIDR format. + + All required parameters must be populated in order to send to Azure. + + :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 + address is allowed. + :vartype ip_address_or_range: str + :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and + "Allow". The default value is None. + :vartype action: str + """ + + _validation = { + 'ip_address_or_range': {'required': True}, + } + + _attribute_map = { + 'ip_address_or_range': {'key': 'value', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + } + + def __init__( + self, + *, + ip_address_or_range: str, + action: Optional[str] = None, + **kwargs + ): + """ + :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 + address is allowed. + :paramtype ip_address_or_range: str + :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and + "Allow". The default value is None. + :paramtype action: str + """ + super(IPRule, self).__init__(**kwargs) + self.ip_address_or_range = ip_address_or_range + self.action = action + + +class KeyCreationTime(msrest.serialization.Model): + """Storage account keys creation time. + + :ivar key1: + :vartype key1: ~datetime.datetime + :ivar key2: + :vartype key2: ~datetime.datetime + """ + + _attribute_map = { + 'key1': {'key': 'key1', 'type': 'iso-8601'}, + 'key2': {'key': 'key2', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + key1: Optional[datetime.datetime] = None, + key2: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword key1: + :paramtype key1: ~datetime.datetime + :keyword key2: + :paramtype key2: ~datetime.datetime + """ + super(KeyCreationTime, self).__init__(**kwargs) + self.key1 = key1 + self.key2 = key2 + + +class KeyPolicy(msrest.serialization.Model): + """KeyPolicy assigned to the storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :vartype key_expiration_period_in_days: int + """ + + _validation = { + 'key_expiration_period_in_days': {'required': True}, + } + + _attribute_map = { + 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + } + + def __init__( + self, + *, + key_expiration_period_in_days: int, + **kwargs + ): + """ + :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :paramtype key_expiration_period_in_days: int + """ + super(KeyPolicy, self).__init__(**kwargs) + self.key_expiration_period_in_days = key_expiration_period_in_days + + +class KeyVaultProperties(msrest.serialization.Model): + """Properties of key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: The name of KeyVault key. + :vartype key_name: str + :ivar key_version: The version of KeyVault key. + :vartype key_version: str + :ivar key_vault_uri: The Uri of KeyVault. + :vartype key_vault_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + :ivar current_versioned_key_expiration_timestamp: This is a read only property that represents + the expiration time of the current version of the customer managed key used for encryption. + :vartype current_versioned_key_expiration_timestamp: ~datetime.datetime + """ + + _validation = { + 'current_versioned_key_identifier': {'readonly': True}, + 'last_key_rotation_timestamp': {'readonly': True}, + 'current_versioned_key_expiration_timestamp': {'readonly': True}, + } + + _attribute_map = { + 'key_name': {'key': 'keyname', 'type': 'str'}, + 'key_version': {'key': 'keyversion', 'type': 'str'}, + 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, + 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + 'current_versioned_key_expiration_timestamp': {'key': 'currentVersionedKeyExpirationTimestamp', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword key_name: The name of KeyVault key. + :paramtype key_name: str + :keyword key_version: The version of KeyVault key. + :paramtype key_version: str + :keyword key_vault_uri: The Uri of KeyVault. + :paramtype key_vault_uri: str + """ + super(KeyVaultProperties, self).__init__(**kwargs) + self.key_name = key_name + self.key_version = key_version + self.key_vault_uri = key_vault_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + self.current_versioned_key_expiration_timestamp = None + + +class LastAccessTimeTrackingPolicy(msrest.serialization.Model): + """The blob service properties for Last access time based tracking policy. + + All required parameters must be populated in order to send to Azure. + + :ivar enable: Required. When set to true last access time based tracking is enabled. + :vartype enable: bool + :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently + read only. Known values are: "AccessTimeTracking". + :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.Name + :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :vartype tracking_granularity_in_days: int + :ivar blob_type: An array of predefined supported blob types. Only blockBlob is the supported + value. This field is currently read only. + :vartype blob_type: list[str] + """ + + _validation = { + 'enable': {'required': True}, + } + + _attribute_map = { + 'enable': {'key': 'enable', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, + 'blob_type': {'key': 'blobType', 'type': '[str]'}, + } + + def __init__( + self, + *, + enable: bool, + name: Optional[Union[str, "_models.Name"]] = None, + tracking_granularity_in_days: Optional[int] = None, + blob_type: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword enable: Required. When set to true last access time based tracking is enabled. + :paramtype enable: bool + :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is + currently read only. Known values are: "AccessTimeTracking". + :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.Name + :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :paramtype tracking_granularity_in_days: int + :keyword blob_type: An array of predefined supported blob types. Only blockBlob is the + supported value. This field is currently read only. + :paramtype blob_type: list[str] + """ + super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + self.enable = enable + self.name = name + self.tracking_granularity_in_days = tracking_granularity_in_days + self.blob_type = blob_type + + +class LeaseContainerRequest(msrest.serialization.Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". + :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseContainerRequestEnum"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs + ): + """ + :keyword action: Required. Specifies the lease action. Can be one of the available actions. + Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super(LeaseContainerRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseContainerResponse(msrest.serialization.Model): + """Lease Container response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + container, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__( + self, + *, + lease_id: Optional[str] = None, + lease_time_seconds: Optional[str] = None, + **kwargs + ): + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the container, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super(LeaseContainerResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LeaseShareRequest(msrest.serialization.Model): + """Lease Share request schema. + + All required parameters must be populated in order to send to Azure. + + :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known + values are: "Acquire", "Renew", "Change", "Release", "Break". + :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + 'action': {'required': True}, + } + + _attribute_map = { + 'action': {'key': 'action', 'type': 'str'}, + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'break_period': {'key': 'breakPeriod', 'type': 'int'}, + 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, + 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseShareAction"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs + ): + """ + :keyword action: Required. Specifies the lease action. Can be one of the available actions. + Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super(LeaseShareRequest, self).__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseShareResponse(msrest.serialization.Model): + """Lease Share response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + share, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + 'lease_id': {'key': 'leaseId', 'type': 'str'}, + 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + } + + def __init__( + self, + *, + lease_id: Optional[str] = None, + lease_time_seconds: Optional[str] = None, + **kwargs + ): + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the share, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super(LeaseShareResponse, self).__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LegalHold(msrest.serialization.Model): + """The LegalHold property of a blob container. + + 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 has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is + normalized to lower case at SRP. + :vartype tags: list[str] + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + 'has_legal_hold': {'readonly': True}, + 'tags': {'required': True}, + } + + _attribute_map = { + 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, + 'tags': {'key': 'tags', 'type': '[str]'}, + 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + } + + def __init__( + self, + *, + tags: List[str], + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and + is normalized to lower case at SRP. + :paramtype tags: list[str] + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super(LegalHold, self).__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class LegalHoldProperties(msrest.serialization.Model): + """The LegalHold property of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :vartype tags: list[~azure.mgmt.storage.v2022_05_01.models.TagProperty] + :ivar protected_append_writes_history: Protected append blob writes history. + :vartype protected_append_writes_history: + ~azure.mgmt.storage.v2022_05_01.models.ProtectedAppendWritesHistory + """ + + _validation = { + 'has_legal_hold': {'readonly': True}, + } + + _attribute_map = { + 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, + 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + 'protected_append_writes_history': {'key': 'protectedAppendWritesHistory', 'type': 'ProtectedAppendWritesHistory'}, + } + + def __init__( + self, + *, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :paramtype tags: list[~azure.mgmt.storage.v2022_05_01.models.TagProperty] + :keyword protected_append_writes_history: Protected append blob writes history. + :paramtype protected_append_writes_history: + ~azure.mgmt.storage.v2022_05_01.models.ProtectedAppendWritesHistory + """ + super(LegalHoldProperties, self).__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.protected_append_writes_history = protected_append_writes_history + + +class ListAccountSasResponse(msrest.serialization.Model): + """The List SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_sas_token: List SAS credentials of storage account. + :vartype account_sas_token: str + """ + + _validation = { + 'account_sas_token': {'readonly': True}, + } + + _attribute_map = { + 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListAccountSasResponse, self).__init__(**kwargs) + self.account_sas_token = None + + +class ListBlobInventoryPolicy(msrest.serialization.Model): + """List of blob inventory policies returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob inventory policies. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListBlobInventoryPolicy, self).__init__(**kwargs) + self.value = None + + +class ListContainerItem(AzureEntityResource): + """The blob container properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", "None". + :vartype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite", "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'etag': {'readonly': True}, + 'version': {'readonly': True}, + 'deleted': {'readonly': True}, + 'deleted_time': {'readonly': True}, + 'remaining_retention_days': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + 'lease_status': {'readonly': True}, + 'lease_state': {'readonly': True}, + 'lease_duration': {'readonly': True}, + 'immutability_policy': {'readonly': True}, + 'legal_hold': {'readonly': True}, + 'has_legal_hold': {'readonly': True}, + 'has_immutability_policy': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, + 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, + 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, + 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, + 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, + 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, + 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, + 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, + 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, + 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, + 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, + 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, + 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs + ): + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super(ListContainerItem, self).__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class ListContainerItems(msrest.serialization.Model): + """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blobs containers returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.ListContainerItem] + :ivar next_link: Request URL that can be used to query next page of containers. Returned when + total number of requested containers exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ListContainerItem]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListContainerItems, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueue(Resource): + """ListQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + """ + + _validation = { + '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'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super(ListQueue, self).__init__(**kwargs) + self.metadata = metadata + + +class ListQueueResource(msrest.serialization.Model): + """Response schema. Contains list of queues returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queues returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.ListQueue] + :ivar next_link: Request URL that can be used to list next page of queues. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ListQueue]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListQueueResource, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueueServices(msrest.serialization.Model): + """ListQueueServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queue services returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListQueueServices, self).__init__(**kwargs) + self.value = None + + +class ListServiceSasResponse(msrest.serialization.Model): + """The List service SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_sas_token: List service SAS credentials of specific resource. + :vartype service_sas_token: str + """ + + _validation = { + 'service_sas_token': {'readonly': True}, + } + + _attribute_map = { + 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListServiceSasResponse, self).__init__(**kwargs) + self.service_sas_token = None + + +class ListTableResource(msrest.serialization.Model): + """Response schema. Contains list of tables returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of tables returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.Table] + :ivar next_link: Request URL that can be used to query next page of tables. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Table]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListTableResource, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListTableServices(msrest.serialization.Model): + """ListTableServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of table services returned. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ListTableServices, self).__init__(**kwargs) + self.value = None + + +class LocalUser(Resource): + """The local user associated with the storage accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2022_05_01.models.SystemData + :ivar permission_scopes: The permission scopes of the local user. + :vartype permission_scopes: list[~azure.mgmt.storage.v2022_05_01.models.PermissionScope] + :ivar home_directory: Optional, local user home directory. + :vartype home_directory: str + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_05_01.models.SshPublicKey] + :ivar sid: A unique Security Identifier that is generated by the server. + :vartype sid: str + :ivar has_shared_key: Indicates whether shared key exists. Set it to false to remove existing + shared key. + :vartype has_shared_key: bool + :ivar has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :vartype has_ssh_key: bool + :ivar has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :vartype has_ssh_password: bool + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'sid': {'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'}, + 'permission_scopes': {'key': 'properties.permissionScopes', 'type': '[PermissionScope]'}, + 'home_directory': {'key': 'properties.homeDirectory', 'type': 'str'}, + 'ssh_authorized_keys': {'key': 'properties.sshAuthorizedKeys', 'type': '[SshPublicKey]'}, + 'sid': {'key': 'properties.sid', 'type': 'str'}, + 'has_shared_key': {'key': 'properties.hasSharedKey', 'type': 'bool'}, + 'has_ssh_key': {'key': 'properties.hasSshKey', 'type': 'bool'}, + 'has_ssh_password': {'key': 'properties.hasSshPassword', 'type': 'bool'}, + } + + def __init__( + self, + *, + permission_scopes: Optional[List["_models.PermissionScope"]] = None, + home_directory: Optional[str] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, + has_shared_key: Optional[bool] = None, + has_ssh_key: Optional[bool] = None, + has_ssh_password: Optional[bool] = None, + **kwargs + ): + """ + :keyword permission_scopes: The permission scopes of the local user. + :paramtype permission_scopes: list[~azure.mgmt.storage.v2022_05_01.models.PermissionScope] + :keyword home_directory: Optional, local user home directory. + :paramtype home_directory: str + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_05_01.models.SshPublicKey] + :keyword has_shared_key: Indicates whether shared key exists. Set it to false to remove + existing shared key. + :paramtype has_shared_key: bool + :keyword has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :paramtype has_ssh_key: bool + :keyword has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :paramtype has_ssh_password: bool + """ + super(LocalUser, self).__init__(**kwargs) + self.system_data = None + self.permission_scopes = permission_scopes + self.home_directory = home_directory + self.ssh_authorized_keys = ssh_authorized_keys + self.sid = None + self.has_shared_key = has_shared_key + self.has_ssh_key = has_ssh_key + self.has_ssh_password = has_ssh_password + + +class LocalUserKeys(msrest.serialization.Model): + """The Storage Account Local User keys. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_05_01.models.SshPublicKey] + :ivar shared_key: Auto generated by the server for SMB authentication. + :vartype shared_key: str + """ + + _validation = { + 'shared_key': {'readonly': True}, + } + + _attribute_map = { + 'ssh_authorized_keys': {'key': 'sshAuthorizedKeys', 'type': '[SshPublicKey]'}, + 'shared_key': {'key': 'sharedKey', 'type': 'str'}, + } + + def __init__( + self, + *, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, + **kwargs + ): + """ + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_05_01.models.SshPublicKey] + """ + super(LocalUserKeys, self).__init__(**kwargs) + self.ssh_authorized_keys = ssh_authorized_keys + self.shared_key = None + + +class LocalUserRegeneratePasswordResult(msrest.serialization.Model): + """The secrets of Storage Account Local User. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_password: Auto generated password by the server for SSH authentication if + hasSshPassword is set to true on the creation of local user. + :vartype ssh_password: str + """ + + _validation = { + 'ssh_password': {'readonly': True}, + } + + _attribute_map = { + 'ssh_password': {'key': 'sshPassword', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(LocalUserRegeneratePasswordResult, self).__init__(**kwargs) + self.ssh_password = None + + +class LocalUsers(msrest.serialization.Model): + """List storage account local users. + + :ivar value: The local users associated with the storage account. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.LocalUser] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[LocalUser]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.LocalUser"]] = None, + **kwargs + ): + """ + :keyword value: The local users associated with the storage account. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.LocalUser] + """ + super(LocalUsers, self).__init__(**kwargs) + self.value = value + + +class ManagementPolicy(Resource): + """The Get Storage Account ManagementPolicies operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :vartype policy: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicySchema + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'last_modified_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + } + + def __init__( + self, + *, + policy: Optional["_models.ManagementPolicySchema"] = None, + **kwargs + ): + """ + :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :paramtype policy: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicySchema + """ + super(ManagementPolicy, self).__init__(**kwargs) + self.last_modified_time = None + self.policy = policy + + +class ManagementPolicyAction(msrest.serialization.Model): + """Actions are applied to the filtered blobs when the execution condition is met. + + :ivar base_blob: The management policy action for base blob. + :vartype base_blob: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyBaseBlob + :ivar snapshot: The management policy action for snapshot. + :vartype snapshot: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicySnapShot + :ivar version: The management policy action for version. + :vartype version: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyVersion + """ + + _attribute_map = { + 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, + 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, + 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + } + + def __init__( + self, + *, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, + **kwargs + ): + """ + :keyword base_blob: The management policy action for base blob. + :paramtype base_blob: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyBaseBlob + :keyword snapshot: The management policy action for snapshot. + :paramtype snapshot: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicySnapShot + :keyword version: The management policy action for version. + :paramtype version: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyVersion + """ + super(ManagementPolicyAction, self).__init__(**kwargs) + self.base_blob = base_blob + self.snapshot = snapshot + self.version = version + + +class ManagementPolicyBaseBlob(msrest.serialization.Model): + """Management policy action for base blob. + + :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot + tier. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :ivar tier_to_archive: The function to tier blobs to archive storage. Support blobs currently + at Hot or Cool tier. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :ivar delete: The function to delete the blob. + :vartype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :ivar enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from cool + to hot on a blob access. This property requires tierToCool.daysAfterLastAccessTimeGreaterThan. + :vartype enable_auto_tier_to_hot_from_cool: bool + """ + + _attribute_map = { + 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, + 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, + 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, + 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, + enable_auto_tier_to_hot_from_cool: Optional[bool] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at + Hot tier. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :keyword tier_to_archive: The function to tier blobs to archive storage. Support blobs + currently at Hot or Cool tier. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :keyword delete: The function to delete the blob. + :paramtype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterModification + :keyword enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from + cool to hot on a blob access. This property requires + tierToCool.daysAfterLastAccessTimeGreaterThan. + :paramtype enable_auto_tier_to_hot_from_cool: bool + """ + super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.delete = delete + self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool + + +class ManagementPolicyDefinition(msrest.serialization.Model): + """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. + + All required parameters must be populated in order to send to Azure. + + :ivar actions: Required. An object that defines the action set. + :vartype actions: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyAction + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyFilter + """ + + _validation = { + 'actions': {'required': True}, + } + + _attribute_map = { + 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, + 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + } + + def __init__( + self, + *, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, + **kwargs + ): + """ + :keyword actions: Required. An object that defines the action set. + :paramtype actions: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyAction + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyFilter + """ + super(ManagementPolicyDefinition, self).__init__(**kwargs) + self.actions = actions + self.filters = filters + + +class ManagementPolicyFilter(msrest.serialization.Model): + """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. + + All required parameters must be populated in order to send to Azure. + + :ivar prefix_match: An array of strings for prefixes to be match. + :vartype prefix_match: list[str] + :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports + all tiering and delete actions. Only delete actions are supported for appendBlob. + :vartype blob_types: list[str] + :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag + filters. + :vartype blob_index_match: list[~azure.mgmt.storage.v2022_05_01.models.TagFilter] + """ + + _validation = { + 'blob_types': {'required': True}, + } + + _attribute_map = { + 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, + 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, + 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + } + + def __init__( + self, + *, + blob_types: List[str], + prefix_match: Optional[List[str]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, + **kwargs + ): + """ + :keyword prefix_match: An array of strings for prefixes to be match. + :paramtype prefix_match: list[str] + :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports + all tiering and delete actions. Only delete actions are supported for appendBlob. + :paramtype blob_types: list[str] + :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 + tag filters. + :paramtype blob_index_match: list[~azure.mgmt.storage.v2022_05_01.models.TagFilter] + """ + super(ManagementPolicyFilter, self).__init__(**kwargs) + self.prefix_match = prefix_match + self.blob_types = blob_types + self.blob_index_match = blob_index_match + + +class ManagementPolicyRule(msrest.serialization.Model): + """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Rule is enabled if set to true. + :vartype enabled: bool + :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule + name is case-sensitive. It must be unique within a policy. + :vartype name: str + :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.RuleType + :ivar definition: Required. An object that defines the Lifecycle rule. + :vartype definition: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyDefinition + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True}, + 'definition': {'required': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + } + + def __init__( + self, + *, + name: str, + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Rule is enabled if set to true. + :paramtype enabled: bool + :keyword name: Required. A rule name can contain any combination of alpha numeric characters. + Rule name is case-sensitive. It must be unique within a policy. + :paramtype name: str + :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.RuleType + :keyword definition: Required. An object that defines the Lifecycle rule. + :paramtype definition: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyDefinition + """ + super(ManagementPolicyRule, self).__init__(**kwargs) + self.enabled = enabled + self.name = name + self.type = type + self.definition = definition + + +class ManagementPolicySchema(msrest.serialization.Model): + """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + + All required parameters must be populated in order to send to Azure. + + :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :vartype rules: list[~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyRule] + """ + + _validation = { + 'rules': {'required': True}, + } + + _attribute_map = { + 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + } + + def __init__( + self, + *, + rules: List["_models.ManagementPolicyRule"], + **kwargs + ): + """ + :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyRule] + """ + super(ManagementPolicySchema, self).__init__(**kwargs) + self.rules = rules + + +class ManagementPolicySnapShot(msrest.serialization.Model): + """Management policy action for snapshot. + + :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot + currently at Hot tier. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob snapshot to archive storage. Support blob + snapshot currently at Hot or Cool tier. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :ivar delete: The function to delete the blob snapshot. + :vartype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + """ + + _attribute_map = { + 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, + 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, + 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blob snapshot to cool storage. Support blob + snapshot currently at Hot tier. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob snapshot to archive storage. Support blob + snapshot currently at Hot or Cool tier. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :keyword delete: The function to delete the blob snapshot. + :paramtype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + """ + super(ManagementPolicySnapShot, self).__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.delete = delete + + +class ManagementPolicyVersion(msrest.serialization.Model): + """Management policy action for blob version. + + :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version + currently at Hot tier. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob version to archive storage. Support blob + version currently at Hot or Cool tier. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :ivar delete: The function to delete the blob version. + :vartype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + """ + + _attribute_map = { + 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, + 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, + 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blob version to cool storage. Support blob version + currently at Hot tier. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob version to archive storage. Support blob + version currently at Hot or Cool tier. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + :keyword delete: The function to delete the blob version. + :paramtype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation + """ + super(ManagementPolicyVersion, self).__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.delete = delete + + +class MetricSpecification(msrest.serialization.Model): + """Metric specification of operation. + + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: Unit could be Bytes or Count. + :vartype unit: str + :ivar dimensions: Dimensions of blobs, including blob type and access tier. + :vartype dimensions: list[~azure.mgmt.storage.v2022_05_01.models.Dimension] + :ivar aggregation_type: Aggregation type could be Average. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: The property to decide fill gap with zero or not. + :vartype fill_gap_with_zero: bool + :ivar category: The category this metric specification belong to, could be Capacity. + :vartype category: str + :ivar resource_id_dimension_name_override: Account Resource Id. + :vartype resource_id_dimension_name_override: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'display_description': {'key': 'displayDescription', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, + 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, + 'category': {'key': 'category', 'type': 'str'}, + 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + dimensions: Optional[List["_models.Dimension"]] = None, + aggregation_type: Optional[str] = None, + fill_gap_with_zero: Optional[bool] = None, + category: Optional[str] = None, + resource_id_dimension_name_override: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of metric specification. + :paramtype name: str + :keyword display_name: Display name of metric specification. + :paramtype display_name: str + :keyword display_description: Display description of metric specification. + :paramtype display_description: str + :keyword unit: Unit could be Bytes or Count. + :paramtype unit: str + :keyword dimensions: Dimensions of blobs, including blob type and access tier. + :paramtype dimensions: list[~azure.mgmt.storage.v2022_05_01.models.Dimension] + :keyword aggregation_type: Aggregation type could be Average. + :paramtype aggregation_type: str + :keyword fill_gap_with_zero: The property to decide fill gap with zero or not. + :paramtype fill_gap_with_zero: bool + :keyword category: The category this metric specification belong to, could be Capacity. + :paramtype category: str + :keyword resource_id_dimension_name_override: Account Resource Id. + :paramtype resource_id_dimension_name_override: str + """ + super(MetricSpecification, self).__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.dimensions = dimensions + self.aggregation_type = aggregation_type + self.fill_gap_with_zero = fill_gap_with_zero + self.category = category + self.resource_id_dimension_name_override = resource_id_dimension_name_override + + +class Multichannel(msrest.serialization.Model): + """Multichannel setting. Applies to Premium FileStorage only. + + :ivar enabled: Indicates whether multichannel is enabled. + :vartype enabled: bool + """ + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Indicates whether multichannel is enabled. + :paramtype enabled: bool + """ + super(Multichannel, self).__init__(**kwargs) + self.enabled = enabled + + +class NetworkRuleSet(msrest.serialization.Model): + """Network rule set. + + All required parameters must be populated in order to send to Azure. + + :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible + values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", + "AzureServices". Default value: "AzureServices". + :vartype bypass: str or ~azure.mgmt.storage.v2022_05_01.models.Bypass + :ivar resource_access_rules: Sets the resource access rules. + :vartype resource_access_rules: list[~azure.mgmt.storage.v2022_05_01.models.ResourceAccessRule] + :ivar virtual_network_rules: Sets the virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.storage.v2022_05_01.models.VirtualNetworkRule] + :ivar ip_rules: Sets the IP ACL rules. + :vartype ip_rules: list[~azure.mgmt.storage.v2022_05_01.models.IPRule] + :ivar default_action: Required. Specifies the default action of allow or deny when no other + rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :vartype default_action: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultAction + """ + + _validation = { + 'default_action': {'required': True}, + } + + _attribute_map = { + 'bypass': {'key': 'bypass', 'type': 'str'}, + 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, + 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, + 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, + 'default_action': {'key': 'defaultAction', 'type': 'str'}, + } + + def __init__( + self, + *, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, + **kwargs + ): + """ + :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. + Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", "AzureServices". Default value: "AzureServices". + :paramtype bypass: str or ~azure.mgmt.storage.v2022_05_01.models.Bypass + :keyword resource_access_rules: Sets the resource access rules. + :paramtype resource_access_rules: + list[~azure.mgmt.storage.v2022_05_01.models.ResourceAccessRule] + :keyword virtual_network_rules: Sets the virtual network rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.storage.v2022_05_01.models.VirtualNetworkRule] + :keyword ip_rules: Sets the IP ACL rules. + :paramtype ip_rules: list[~azure.mgmt.storage.v2022_05_01.models.IPRule] + :keyword default_action: Required. Specifies the default action of allow or deny when no other + rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :paramtype default_action: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultAction + """ + super(NetworkRuleSet, self).__init__(**kwargs) + self.bypass = bypass + self.resource_access_rules = resource_access_rules + self.virtual_network_rules = virtual_network_rules + self.ip_rules = ip_rules + self.default_action = default_action + + +class ObjectReplicationPolicies(msrest.serialization.Model): + """List storage account object replication policies. + + :ivar value: The replication policy between two storage accounts. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.ObjectReplicationPolicy"]] = None, + **kwargs + ): + """ + :keyword value: The replication policy between two storage accounts. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy] + """ + super(ObjectReplicationPolicies, self).__init__(**kwargs) + self.value = value + + +class ObjectReplicationPolicy(Resource): + """The replication policy between two storage accounts. Multiple rules can be defined in one policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar policy_id: A unique id for object replication policy. + :vartype policy_id: str + :ivar enabled_time: Indicates when the policy is enabled on the source account. + :vartype enabled_time: ~datetime.datetime + :ivar source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype source_account: str + :ivar destination_account: Required. Destination account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype destination_account: str + :ivar rules: The storage account object replication rules. + :vartype rules: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyRule] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'policy_id': {'readonly': True}, + 'enabled_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, + 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, + 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, + 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, + 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + } + + def __init__( + self, + *, + source_account: Optional[str] = None, + destination_account: Optional[str] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, + **kwargs + ): + """ + :keyword source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :paramtype source_account: str + :keyword destination_account: Required. Destination account name. It should be full resource id + if allowCrossTenantReplication set to false. + :paramtype destination_account: str + :keyword rules: The storage account object replication rules. + :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyRule] + """ + super(ObjectReplicationPolicy, self).__init__(**kwargs) + self.policy_id = None + self.enabled_time = None + self.source_account = source_account + self.destination_account = destination_account + self.rules = rules + + +class ObjectReplicationPolicyFilter(msrest.serialization.Model): + """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. + + :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :vartype prefix_match: list[str] + :ivar min_creation_time: Blobs created after the time will be replicated to the destination. It + must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :vartype min_creation_time: str + """ + + _attribute_map = { + 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, + 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + } + + def __init__( + self, + *, + prefix_match: Optional[List[str]] = None, + min_creation_time: Optional[str] = None, + **kwargs + ): + """ + :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :paramtype prefix_match: list[str] + :keyword min_creation_time: Blobs created after the time will be replicated to the destination. + It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :paramtype min_creation_time: str + """ + super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + self.prefix_match = prefix_match + self.min_creation_time = min_creation_time + + +class ObjectReplicationPolicyRule(msrest.serialization.Model): + """The replication policy rule between two containers. + + All required parameters must be populated in order to send to Azure. + + :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :vartype rule_id: str + :ivar source_container: Required. Required. Source container name. + :vartype source_container: str + :ivar destination_container: Required. Required. Destination container name. + :vartype destination_container: str + :ivar filters: Optional. An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyFilter + """ + + _validation = { + 'source_container': {'required': True}, + 'destination_container': {'required': True}, + } + + _attribute_map = { + 'rule_id': {'key': 'ruleId', 'type': 'str'}, + 'source_container': {'key': 'sourceContainer', 'type': 'str'}, + 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, + 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + } + + def __init__( + self, + *, + source_container: str, + destination_container: str, + rule_id: Optional[str] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, + **kwargs + ): + """ + :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :paramtype rule_id: str + :keyword source_container: Required. Required. Source container name. + :paramtype source_container: str + :keyword destination_container: Required. Required. Destination container name. + :paramtype destination_container: str + :keyword filters: Optional. An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyFilter + """ + super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + self.rule_id = rule_id + self.source_container = source_container + self.destination_container = destination_container + self.filters = filters + + +class Operation(msrest.serialization.Model): + """Storage REST API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.storage.v2022_05_01.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.storage.v2022_05_01.models.ServiceSpecification + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.storage.v2022_05_01.models.OperationDisplay + :keyword origin: The origin of operations. + :paramtype origin: str + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: ~azure.mgmt.storage.v2022_05_01.models.ServiceSpecification + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + self.service_specification = service_specification + + +class OperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft Storage. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft Storage. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(msrest.serialization.Model): + """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of Storage operations supported by the Storage resource provider. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.Operation] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Operation"]] = None, + **kwargs + ): + """ + :keyword value: List of Storage operations supported by the Storage resource provider. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.Operation] + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + + +class PermissionScope(msrest.serialization.Model): + """PermissionScope. + + All required parameters must be populated in order to send to Azure. + + :ivar permissions: Required. The permissions for the local user. Possible values include: Read + (r), Write (w), Delete (d), List (l), and Create (c). + :vartype permissions: str + :ivar service: Required. The service used by the local user, e.g. blob, file. + :vartype service: str + :ivar resource_name: Required. The name of resource, normally the container name or the file + share name, used by the local user. + :vartype resource_name: str + """ + + _validation = { + 'permissions': {'required': True}, + 'service': {'required': True}, + 'resource_name': {'required': True}, + } + + _attribute_map = { + 'permissions': {'key': 'permissions', 'type': 'str'}, + 'service': {'key': 'service', 'type': 'str'}, + 'resource_name': {'key': 'resourceName', 'type': 'str'}, + } + + def __init__( + self, + *, + permissions: str, + service: str, + resource_name: str, + **kwargs + ): + """ + :keyword permissions: Required. The permissions for the local user. Possible values include: + Read (r), Write (w), Delete (d), List (l), and Create (c). + :paramtype permissions: str + :keyword service: Required. The service used by the local user, e.g. blob, file. + :paramtype service: str + :keyword resource_name: Required. The name of resource, normally the container name or the file + share name, used by the local user. + :paramtype resource_name: str + """ + super(PermissionScope, self).__init__(**kwargs) + self.permissions = permissions + self.service = service + self.resource_name = resource_name + + +class PrivateEndpoint(msrest.serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + 'id': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PrivateEndpoint, self).__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(Resource): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'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': 'PrivateLinkServiceConnectionState'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkServiceConnectionState + """ + super(PrivateEndpointConnection, self).__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(msrest.serialization.Model): + """List of private endpoint connection associated with the specified storage account. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, + **kwargs + ): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] + """ + super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateLinkResource(Resource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'group_id': {'readonly': True}, + 'required_members': {'readonly': True}, + } + + _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]'}, + } + + def __init__( + self, + *, + required_zone_names: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super(PrivateLinkResource, self).__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(msrest.serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResource] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.PrivateLinkResource"]] = None, + **kwargs + ): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResource] + """ + super(PrivateLinkResourceListResult, self).__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(msrest.serialization.Model): + """A collection of information about the state of the connection between service consumer and provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", "Rejected". + :vartype status: str or + ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype action_required: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'action_required': {'key': 'actionRequired', 'type': 'str'}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + action_required: Optional[str] = None, + **kwargs + ): + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", "Rejected". + :paramtype status: str or + ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype action_required: str + """ + super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + self.status = status + self.description = description + self.action_required = action_required + + +class ProtectedAppendWritesHistory(msrest.serialization.Model): + """Protected append writes history setting for the blob container with Legal holds. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + """ + + _validation = { + 'timestamp': {'readonly': True}, + } + + _attribute_map = { + 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super(ProtectedAppendWritesHistory, self).__init__(**kwargs) + self.allow_protected_append_writes_all = allow_protected_append_writes_all + self.timestamp = None + + +class ProtocolSettings(msrest.serialization.Model): + """Protocol settings for file service. + + :ivar smb: Setting for SMB protocol. + :vartype smb: ~azure.mgmt.storage.v2022_05_01.models.SmbSetting + """ + + _attribute_map = { + 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + } + + def __init__( + self, + *, + smb: Optional["_models.SmbSetting"] = None, + **kwargs + ): + """ + :keyword smb: Setting for SMB protocol. + :paramtype smb: ~azure.mgmt.storage.v2022_05_01.models.SmbSetting + """ + super(ProtocolSettings, self).__init__(**kwargs) + self.smb = smb + + +class QueueServiceProperties(Resource): + """The properties of a storage account’s Queue service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :vartype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + """ + + _validation = { + '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'}, + 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + """ + super(QueueServiceProperties, self).__init__(**kwargs) + self.cors = cors + + +class ResourceAccessRule(msrest.serialization.Model): + """Resource Access Rule. + + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar resource_id: Resource Id. + :vartype resource_id: str + """ + + _attribute_map = { + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'resource_id': {'key': 'resourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + tenant_id: Optional[str] = None, + resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword tenant_id: Tenant Id. + :paramtype tenant_id: str + :keyword resource_id: Resource Id. + :paramtype resource_id: str + """ + super(ResourceAccessRule, self).__init__(**kwargs) + self.tenant_id = tenant_id + self.resource_id = resource_id + + +class RestorePolicyProperties(msrest.serialization.Model): + """The blob service properties for blob restore policy. + + 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 enabled: Required. Blob restore is enabled if set to true. + :vartype enabled: bool + :ivar days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :vartype days: int + :ivar last_enabled_time: Deprecated in favor of minRestoreTime property. + :vartype last_enabled_time: ~datetime.datetime + :ivar min_restore_time: Returns the minimum date and time that the restore can be started. + :vartype min_restore_time: ~datetime.datetime + """ + + _validation = { + 'enabled': {'required': True}, + 'days': {'maximum': 365, 'minimum': 1}, + 'last_enabled_time': {'readonly': True}, + 'min_restore_time': {'readonly': True}, + } + + _attribute_map = { + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'days': {'key': 'days', 'type': 'int'}, + 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + enabled: bool, + days: Optional[int] = None, + **kwargs + ): + """ + :keyword enabled: Required. Blob restore is enabled if set to true. + :paramtype enabled: bool + :keyword days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :paramtype days: int + """ + super(RestorePolicyProperties, self).__init__(**kwargs) + self.enabled = enabled + self.days = days + self.last_enabled_time = None + self.min_restore_time = None + + +class Restriction(msrest.serialization.Model): + """The restriction because of which SKU cannot be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. As of now only possible value for this is location. + :vartype type: str + :ivar values: The value of restrictions. If the restriction type is set to location. This would + be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + :vartype reason_code: str or ~azure.mgmt.storage.v2022_05_01.models.ReasonCode + """ + + _validation = { + 'type': {'readonly': True}, + 'values': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + } + + def __init__( + self, + *, + reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, + **kwargs + ): + """ + :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + :paramtype reason_code: str or ~azure.mgmt.storage.v2022_05_01.models.ReasonCode + """ + super(Restriction, self).__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = reason_code + + +class RoutingPreference(msrest.serialization.Model): + """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. + + :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting", "InternetRouting". + :vartype routing_choice: str or ~azure.mgmt.storage.v2022_05_01.models.RoutingChoice + :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :vartype publish_microsoft_endpoints: bool + :ivar publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :vartype publish_internet_endpoints: bool + """ + + _attribute_map = { + 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, + 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, + 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + } + + def __init__( + self, + *, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, + publish_microsoft_endpoints: Optional[bool] = None, + publish_internet_endpoints: Optional[bool] = None, + **kwargs + ): + """ + :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting", "InternetRouting". + :paramtype routing_choice: str or ~azure.mgmt.storage.v2022_05_01.models.RoutingChoice + :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :paramtype publish_microsoft_endpoints: bool + :keyword publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :paramtype publish_internet_endpoints: bool + """ + super(RoutingPreference, self).__init__(**kwargs) + self.routing_choice = routing_choice + self.publish_microsoft_endpoints = publish_microsoft_endpoints + self.publish_internet_endpoints = publish_internet_endpoints + + +class SasPolicy(msrest.serialization.Model): + """SasPolicy assigned to the storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :vartype sas_expiration_period: str + :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". + :vartype expiration_action: str or ~azure.mgmt.storage.v2022_05_01.models.ExpirationAction + """ + + _validation = { + 'sas_expiration_period': {'required': True}, + 'expiration_action': {'required': True}, + } + + _attribute_map = { + 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, + 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + } + + def __init__( + self, + *, + sas_expiration_period: str, + expiration_action: Union[str, "_models.ExpirationAction"] = "Log", + **kwargs + ): + """ + :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :paramtype sas_expiration_period: str + :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values + are: "Log". Default value: "Log". + :paramtype expiration_action: str or ~azure.mgmt.storage.v2022_05_01.models.ExpirationAction + """ + super(SasPolicy, self).__init__(**kwargs) + self.sas_expiration_period = sas_expiration_period + self.expiration_action = expiration_action + + +class ServiceSasParameters(msrest.serialization.Model): + """The parameters to list service SAS credentials of a specific resource. + + All required parameters must be populated in order to send to Azure. + + :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :vartype canonicalized_resource: str + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + :vartype resource: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResource + :ivar permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". + :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http", "https". + :vartype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :vartype identifier: str + :ivar partition_key_start: The start of partition key. + :vartype partition_key_start: str + :ivar partition_key_end: The end of partition key. + :vartype partition_key_end: str + :ivar row_key_start: The start of row key. + :vartype row_key_start: str + :ivar row_key_end: The end of row key. + :vartype row_key_end: str + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + :ivar cache_control: The response header override for cache control. + :vartype cache_control: str + :ivar content_disposition: The response header override for content disposition. + :vartype content_disposition: str + :ivar content_encoding: The response header override for content encoding. + :vartype content_encoding: str + :ivar content_language: The response header override for content language. + :vartype content_language: str + :ivar content_type: The response header override for content type. + :vartype content_type: str + """ + + _validation = { + 'canonicalized_resource': {'required': True}, + 'identifier': {'max_length': 64, 'min_length': 0}, + } + + _attribute_map = { + 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, + 'resource': {'key': 'signedResource', 'type': 'str'}, + 'permissions': {'key': 'signedPermission', 'type': 'str'}, + 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, + 'protocols': {'key': 'signedProtocol', 'type': 'str'}, + 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, + 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, + 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, + 'partition_key_start': {'key': 'startPk', 'type': 'str'}, + 'partition_key_end': {'key': 'endPk', 'type': 'str'}, + 'row_key_start': {'key': 'startRk', 'type': 'str'}, + 'row_key_end': {'key': 'endRk', 'type': 'str'}, + 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + 'cache_control': {'key': 'rscc', 'type': 'str'}, + 'content_disposition': {'key': 'rscd', 'type': 'str'}, + 'content_encoding': {'key': 'rsce', 'type': 'str'}, + 'content_language': {'key': 'rscl', 'type': 'str'}, + 'content_type': {'key': 'rsct', 'type': 'str'}, + } + + def __init__( + self, + *, + canonicalized_resource: str, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + shared_access_expiry_time: Optional[datetime.datetime] = None, + identifier: Optional[str] = None, + partition_key_start: Optional[str] = None, + partition_key_end: Optional[str] = None, + row_key_start: Optional[str] = None, + row_key_end: Optional[str] = None, + key_to_sign: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_type: Optional[str] = None, + **kwargs + ): + """ + :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :paramtype canonicalized_resource: str + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + :paramtype resource: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResource + :keyword permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http", "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :paramtype identifier: str + :keyword partition_key_start: The start of partition key. + :paramtype partition_key_start: str + :keyword partition_key_end: The end of partition key. + :paramtype partition_key_end: str + :keyword row_key_start: The start of row key. + :paramtype row_key_start: str + :keyword row_key_end: The end of row key. + :paramtype row_key_end: str + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + :keyword cache_control: The response header override for cache control. + :paramtype cache_control: str + :keyword content_disposition: The response header override for content disposition. + :paramtype content_disposition: str + :keyword content_encoding: The response header override for content encoding. + :paramtype content_encoding: str + :keyword content_language: The response header override for content language. + :paramtype content_language: str + :keyword content_type: The response header override for content type. + :paramtype content_type: str + """ + super(ServiceSasParameters, self).__init__(**kwargs) + self.canonicalized_resource = canonicalized_resource + self.resource = resource + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.identifier = identifier + self.partition_key_start = partition_key_start + self.partition_key_end = partition_key_end + self.row_key_start = row_key_start + self.row_key_end = row_key_end + self.key_to_sign = key_to_sign + self.cache_control = cache_control + self.content_disposition = content_disposition + self.content_encoding = content_encoding + self.content_language = content_language + self.content_type = content_type + + +class ServiceSpecification(msrest.serialization.Model): + """One property of operation, include metric specifications. + + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: + list[~azure.mgmt.storage.v2022_05_01.models.MetricSpecification] + """ + + _attribute_map = { + 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + } + + def __init__( + self, + *, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, + **kwargs + ): + """ + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: + list[~azure.mgmt.storage.v2022_05_01.models.MetricSpecification] + """ + super(ServiceSpecification, self).__init__(**kwargs) + self.metric_specifications = metric_specifications + + +class SignedIdentifier(msrest.serialization.Model): + """SignedIdentifier. + + :ivar id: An unique identifier of the stored access policy. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2022_05_01.models.AccessPolicy + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + access_policy: Optional["_models.AccessPolicy"] = None, + **kwargs + ): + """ + :keyword id: An unique identifier of the stored access policy. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2022_05_01.models.AccessPolicy + """ + super(SignedIdentifier, self).__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class Sku(msrest.serialization.Model): + """The SKU of the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2022_05_01.models.SkuTier + """ + + _validation = { + 'name': {'required': True}, + 'tier': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + **kwargs + ): + """ + :keyword name: Required. The SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + """ + super(Sku, self).__init__(**kwargs) + self.name = name + self.tier = None + + +class SKUCapability(msrest.serialization.Model): + """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of capability, The capability information in the specified SKU, including + file encryption, network ACLs, change notification, etc. + :vartype name: str + :ivar value: A string value to indicate states of given capability. Possibly 'true' or 'false'. + :vartype value: str + """ + + _validation = { + 'name': {'readonly': True}, + 'value': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(SKUCapability, self).__init__(**kwargs) + self.name = None + self.value = None + + +class SkuInformation(msrest.serialization.Model): + """Storage SKU and its properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2022_05_01.models.SkuTier + :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. + :vartype resource_type: str + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :ivar capabilities: The capability information in the specified SKU, including file encryption, + network ACLs, change notification, etc. + :vartype capabilities: list[~azure.mgmt.storage.v2022_05_01.models.SKUCapability] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.storage.v2022_05_01.models.Restriction] + """ + + _validation = { + 'name': {'required': True}, + 'tier': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'kind': {'readonly': True}, + 'locations': {'readonly': True}, + 'capabilities': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'tier': {'key': 'tier', 'type': 'str'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, + 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + } + + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, + **kwargs + ): + """ + :keyword name: Required. The SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :paramtype restrictions: list[~azure.mgmt.storage.v2022_05_01.models.Restriction] + """ + super(SkuInformation, self).__init__(**kwargs) + self.name = name + self.tier = None + self.resource_type = None + self.kind = None + self.locations = None + self.capabilities = None + self.restrictions = restrictions + + +class SmbSetting(msrest.serialization.Model): + """Setting for SMB protocol. + + :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. + :vartype multichannel: ~azure.mgmt.storage.v2022_05_01.models.Multichannel + :ivar versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :vartype versions: str + :ivar authentication_methods: SMB authentication methods supported by server. Valid values are + NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :vartype authentication_methods: str + :ivar kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid values + are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :vartype kerberos_ticket_encryption: str + :ivar channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :vartype channel_encryption: str + """ + + _attribute_map = { + 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, + 'versions': {'key': 'versions', 'type': 'str'}, + 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, + 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, + 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + } + + def __init__( + self, + *, + multichannel: Optional["_models.Multichannel"] = None, + versions: Optional[str] = None, + authentication_methods: Optional[str] = None, + kerberos_ticket_encryption: Optional[str] = None, + channel_encryption: Optional[str] = None, + **kwargs + ): + """ + :keyword multichannel: Multichannel setting. Applies to Premium FileStorage only. + :paramtype multichannel: ~azure.mgmt.storage.v2022_05_01.models.Multichannel + :keyword versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :paramtype versions: str + :keyword authentication_methods: SMB authentication methods supported by server. Valid values + are NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :paramtype authentication_methods: str + :keyword kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid + values are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :paramtype kerberos_ticket_encryption: str + :keyword channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :paramtype channel_encryption: str + """ + super(SmbSetting, self).__init__(**kwargs) + self.multichannel = multichannel + self.versions = versions + self.authentication_methods = authentication_methods + self.kerberos_ticket_encryption = kerberos_ticket_encryption + self.channel_encryption = channel_encryption + + +class SshPublicKey(msrest.serialization.Model): + """SshPublicKey. + + :ivar description: Optional. It is used to store the function/usage of the key. + :vartype description: str + :ivar key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :vartype key: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'key': {'key': 'key', 'type': 'str'}, + } + + def __init__( + self, + *, + description: Optional[str] = None, + key: Optional[str] = None, + **kwargs + ): + """ + :keyword description: Optional. It is used to store the function/usage of the key. + :paramtype description: str + :keyword key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :paramtype key: str + """ + super(SshPublicKey, self).__init__(**kwargs) + self.description = description + self.key = key + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + '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'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class StorageAccount(TrackedResource): + """The storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar sku: Gets the SKU. + :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", + "FileStorage", "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation + :ivar provisioning_state: Gets the status of the storage account at the time the operation was + called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.storage.v2022_05_01.models.ProvisioningState + :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob + endpoint. + :vartype primary_endpoints: ~azure.mgmt.storage.v2022_05_01.models.Endpoints + :ivar primary_location: Gets the location of the primary data center for the storage account. + :vartype primary_location: str + :ivar status_of_primary: Gets the status indicating whether the primary location of the storage + account is available or unavailable. Known values are: "available", "unavailable". + :vartype status_of_primary: str or ~azure.mgmt.storage.v2022_05_01.models.AccountStatus + :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to + the secondary location. Only the most recent timestamp is retained. This element is not + returned if there has never been a failover instance. Only available if the accountType is + Standard_GRS or Standard_RAGRS. + :vartype last_geo_failover_time: ~datetime.datetime + :ivar secondary_location: Gets the location of the geo-replicated secondary for the storage + account. Only available if the accountType is Standard_GRS or Standard_RAGRS. + :vartype secondary_location: str + :ivar status_of_secondary: Gets the status indicating whether the secondary location of the + storage account is available or unavailable. Only available if the SKU name is Standard_GRS or + Standard_RAGRS. Known values are: "available", "unavailable". + :vartype status_of_secondary: str or ~azure.mgmt.storage.v2022_05_01.models.AccountStatus + :ivar creation_time: Gets the creation date and time of the storage account in UTC. + :vartype creation_time: ~datetime.datetime + :ivar custom_domain: Gets the custom domain the user assigned to this storage account. + :vartype custom_domain: ~azure.mgmt.storage.v2022_05_01.models.CustomDomain + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_05_01.models.KeyPolicy + :ivar key_creation_time: Storage account keys creation time. + :vartype key_creation_time: ~azure.mgmt.storage.v2022_05_01.models.KeyCreationTime + :ivar secondary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object from the secondary location of the storage account. Only available if + the SKU name is Standard_RAGRS. + :vartype secondary_endpoints: ~azure.mgmt.storage.v2022_05_01.models.Endpoints + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2022_05_01.models.Encryption + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar geo_replication_stats: Geo Replication Stats. + :vartype geo_replication_stats: ~azure.mgmt.storage.v2022_05_01.models.GeoReplicationStats + :ivar failover_in_progress: If the failover is in progress, the value will be true, otherwise, + it will be null. + :vartype failover_in_progress: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :ivar private_endpoint_connections: List of private endpoint connection associated with the + specified storage account. + :vartype private_endpoint_connections: + list[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :ivar blob_restore_status: Blob restore status. + :vartype blob_restore_status: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :vartype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountSkuConversionStatus + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'sku': {'readonly': True}, + 'kind': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'primary_endpoints': {'readonly': True}, + 'primary_location': {'readonly': True}, + 'status_of_primary': {'readonly': True}, + 'last_geo_failover_time': {'readonly': True}, + 'secondary_location': {'readonly': True}, + 'status_of_secondary': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'custom_domain': {'readonly': True}, + 'sas_policy': {'readonly': True}, + 'key_policy': {'readonly': True}, + 'key_creation_time': {'readonly': True}, + 'secondary_endpoints': {'readonly': True}, + 'encryption': {'readonly': True}, + 'access_tier': {'readonly': True}, + 'network_rule_set': {'readonly': True}, + 'geo_replication_stats': {'readonly': True}, + 'failover_in_progress': {'readonly': True}, + 'private_endpoint_connections': {'readonly': True}, + 'blob_restore_status': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, + 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, + 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, + 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, + 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, + 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, + 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, + 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, + 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, + 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, + 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, + 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, + 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, + 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, + 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, + 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, + 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, + 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, + 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, + 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, + 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, + 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, + 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, + 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, + 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, + 'storage_account_sku_conversion_status': {'key': 'properties.storageAccountSkuConversionStatus', 'type': 'StorageAccountSkuConversionStatus'}, + 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + storage_account_sku_conversion_status: Optional["_models.StorageAccountSkuConversionStatus"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :keyword extended_location: The extendedLocation of the resource. + :paramtype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :paramtype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountSkuConversionStatus + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard", "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + self.sku = None + self.kind = None + self.identity = identity + self.extended_location = extended_location + self.provisioning_state = None + self.primary_endpoints = None + self.primary_location = None + self.status_of_primary = None + self.last_geo_failover_time = None + self.secondary_location = None + self.status_of_secondary = None + self.creation_time = None + self.custom_domain = None + self.sas_policy = None + self.key_policy = None + self.key_creation_time = None + self.secondary_endpoints = None + self.encryption = None + self.access_tier = None + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.network_rule_set = None + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.is_hns_enabled = is_hns_enabled + self.geo_replication_stats = None + self.failover_in_progress = None + self.large_file_shares_state = large_file_shares_state + self.private_endpoint_connections = None + self.routing_preference = routing_preference + self.blob_restore_status = None + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.storage_account_sku_conversion_status = storage_account_sku_conversion_status + self.dns_endpoint_type = dns_endpoint_type + + +class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): + """The parameters used to check the availability of the storage account name. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. The storage account name. + :vartype name: str + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + type = "Microsoft.Storage/storageAccounts" + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. The storage account name. + :paramtype name: str + """ + super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + self.name = name + + +class StorageAccountCreateParameters(msrest.serialization.Model): + """The parameters used when creating a storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar sku: Required. Required. Gets or sets the SKU name. + :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :ivar kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :ivar location: Required. Required. Gets or sets the location of the resource. This will be one + of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, + etc.). The geo region of a resource cannot be changed once it is created, but if an identical + geo region is specified on update, the request will succeed. + :vartype location: str + :ivar extended_location: Optional. Set the extended location of the resource. If not set, the + storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :vartype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + These tags can be used for viewing and grouping this resource (across resource groups). A + maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no + greater than 128 characters and a value with a length no greater than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_05_01.models.KeyPolicy + :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2022_05_01.models.CustomDomain + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2022_05_01.models.Encryption + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + The default value is true since API version 2019-04-01. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the new containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + + _validation = { + 'sku': {'required': True}, + 'kind': {'required': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, + 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, + 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, + 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, + 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, + 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, + 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, + 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, + 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, + 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, + 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, + 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, + 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, + 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, + 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, + } + + def __init__( + self, + *, + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword sku: Required. Required. Gets or sets the SKU name. + :paramtype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :keyword kind: Required. Required. Indicates the type of storage account. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :keyword location: Required. Required. Gets or sets the location of the resource. This will be + one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, + etc.). The geo region of a resource cannot be changed once it is created, but if an identical + geo region is specified on update, the request will succeed. + :paramtype location: str + :keyword extended_location: Optional. Set the extended location of the resource. If not set, + the storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :paramtype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used for viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a + length no greater than 128 characters and a value with a length no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2022_05_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2022_05_01.models.KeyPolicy + :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2022_05_01.models.CustomDomain + :keyword encryption: Encryption settings to be used for server-side encryption for the storage + account. + :paramtype encryption: ~azure.mgmt.storage.v2022_05_01.models.Encryption + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. The default value is true since API version 2019-04-01. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the new containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard", "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + super(StorageAccountCreateParameters, self).__init__(**kwargs) + self.sku = sku + self.kind = kind + self.location = location + self.extended_location = extended_location + self.tags = tags + self.identity = identity + self.allowed_copy_scope = allowed_copy_scope + self.public_network_access = public_network_access + self.sas_policy = sas_policy + self.key_policy = key_policy + self.custom_domain = custom_domain + self.encryption = encryption + self.network_rule_set = network_rule_set + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.is_hns_enabled = is_hns_enabled + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.dns_endpoint_type = dns_endpoint_type + + +class StorageAccountInternetEndpoints(msrest.serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + 'blob': {'readonly': True}, + 'file': {'readonly': True}, + 'web': {'readonly': True}, + 'dfs': {'readonly': True}, + } + + _attribute_map = { + 'blob': {'key': 'blob', 'type': 'str'}, + 'file': {'key': 'file', 'type': 'str'}, + 'web': {'key': 'web', 'type': 'str'}, + 'dfs': {'key': 'dfs', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + self.blob = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountKey(msrest.serialization.Model): + """An access key for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: Name of the key. + :vartype key_name: str + :ivar value: Base 64-encoded value of the key. + :vartype value: str + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read", "Full". + :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.KeyPermission + :ivar creation_time: Creation time of the key, in round trip date format. + :vartype creation_time: ~datetime.datetime + """ + + _validation = { + 'key_name': {'readonly': True}, + 'value': {'readonly': True}, + 'permissions': {'readonly': True}, + 'creation_time': {'readonly': True}, + } + + _attribute_map = { + 'key_name': {'key': 'keyName', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'permissions': {'key': 'permissions', 'type': 'str'}, + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageAccountKey, self).__init__(**kwargs) + self.key_name = None + self.value = None + self.permissions = None + self.creation_time = None + + +class StorageAccountListKeysResult(msrest.serialization.Model): + """The response from the ListKeys operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar keys: Gets the list of storage account keys and their properties for the specified + storage account. + :vartype keys: list[~azure.mgmt.storage.v2022_05_01.models.StorageAccountKey] + """ + + _validation = { + 'keys': {'readonly': True}, + } + + _attribute_map = { + 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageAccountListKeysResult, self).__init__(**kwargs) + self.keys = None + + +class StorageAccountListResult(msrest.serialization.Model): + """The response from the List Storage Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of storage accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :ivar next_link: Request URL that can be used to query next page of storage accounts. Returned + when total number of requested storage accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[StorageAccount]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageAccountListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + 'blob': {'readonly': True}, + 'queue': {'readonly': True}, + 'table': {'readonly': True}, + 'file': {'readonly': True}, + 'web': {'readonly': True}, + 'dfs': {'readonly': True}, + } + + _attribute_map = { + 'blob': {'key': 'blob', 'type': 'str'}, + 'queue': {'key': 'queue', 'type': 'str'}, + 'table': {'key': 'table', 'type': 'str'}, + 'file': {'key': 'file', 'type': 'str'}, + 'web': {'key': 'web', 'type': 'str'}, + 'dfs': {'key': 'dfs', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): + """The parameters used to regenerate the storage account key. + + All required parameters must be populated in order to send to Azure. + + :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values + are key1, key2, kerb1, kerb2. + :vartype key_name: str + """ + + _validation = { + 'key_name': {'required': True}, + } + + _attribute_map = { + 'key_name': {'key': 'keyName', 'type': 'str'}, + } + + def __init__( + self, + *, + key_name: str, + **kwargs + ): + """ + :keyword key_name: Required. The name of storage keys that want to be regenerated, possible + values are key1, key2, kerb1, kerb2. + :paramtype key_name: str + """ + super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + self.key_name = key_name + + +class StorageAccountSkuConversionStatus(msrest.serialization.Model): + """This defines the sku conversion status object for asynchronous sku conversions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku_conversion_status: This property indicates the current sku conversion status. Known + values are: "InProgress", "Succeeded", "Failed". + :vartype sku_conversion_status: str or + ~azure.mgmt.storage.v2022_05_01.models.SkuConversionStatus + :ivar target_sku_name: This property represents the target sku name to which the account sku is + being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGZRS". + :vartype target_sku_name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + :ivar start_time: This property represents the sku conversion start time. + :vartype start_time: str + :ivar end_time: This property represents the sku conversion end time. + :vartype end_time: str + """ + + _validation = { + 'sku_conversion_status': {'readonly': True}, + 'start_time': {'readonly': True}, + 'end_time': {'readonly': True}, + } + + _attribute_map = { + 'sku_conversion_status': {'key': 'skuConversionStatus', 'type': 'str'}, + 'target_sku_name': {'key': 'targetSkuName', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + } + + def __init__( + self, + *, + target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, + **kwargs + ): + """ + :keyword target_sku_name: This property represents the target sku name to which the account sku + is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGZRS". + :paramtype target_sku_name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName + """ + super(StorageAccountSkuConversionStatus, self).__init__(**kwargs) + self.sku_conversion_status = None + self.target_sku_name = target_sku_name + self.start_time = None + self.end_time = None + + +class StorageAccountUpdateParameters(msrest.serialization.Model): + """The parameters that can be provided when updating the storage account properties. + + :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, + Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. + :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + These tags can be used in viewing and grouping this resource (across resource groups). A + maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in + length than 128 characters and a value no greater in length than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2022_05_01.models.CustomDomain + :ivar encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :vartype encryption: ~azure.mgmt.storage.v2022_05_01.models.Encryption + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_05_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_05_01.models.KeyPolicy + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard", "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + + _attribute_map = { + 'sku': {'key': 'sku', 'type': 'Sku'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, + 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, + 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, + 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, + 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, + 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, + 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, + 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, + 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, + 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, + 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, + 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, + 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, + 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, + 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, + 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, + 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, + } + + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to + Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any + other value. + :paramtype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no + greater in length than 128 characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity + :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind + :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2022_05_01.models.CustomDomain + :keyword encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :paramtype encryption: ~azure.mgmt.storage.v2022_05_01.models.Encryption + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2022_05_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2022_05_01.models.KeyPolicy + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_05_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled", "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_05_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard", "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType + """ + super(StorageAccountUpdateParameters, self).__init__(**kwargs) + self.sku = sku + self.tags = tags + self.identity = identity + self.kind = kind + self.custom_domain = custom_domain + self.encryption = encryption + self.sas_policy = sas_policy + self.key_policy = key_policy + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.network_rule_set = network_rule_set + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.dns_endpoint_type = dns_endpoint_type + + +class StorageQueue(Resource): + """StorageQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + :ivar approximate_message_count: Integer indicating an approximate number of messages in the + queue. This number is not lower than the actual number of messages in the queue, but could be + higher. + :vartype approximate_message_count: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'approximate_message_count': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super(StorageQueue, self).__init__(**kwargs) + self.metadata = metadata + self.approximate_message_count = None + + +class StorageSkuListResult(msrest.serialization.Model): + """The response from the List Storage SKUs operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Get the list result of storage SKUs and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.SkuInformation] + """ + + _validation = { + 'value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SkuInformation]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(StorageSkuListResult, self).__init__(**kwargs) + self.value = None + + +class SystemData(msrest.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". + :vartype created_by_type: str or ~azure.mgmt.storage.v2022_05_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". + :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2022_05_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.storage.v2022_05_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". + :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2022_05_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class Table(Resource): + """Properties of the table, including Id, resource name, resource type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar table_name: Table name under the specified account. + :vartype table_name: str + :ivar signed_identifiers: List of stored access policies specified on the table. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.TableSignedIdentifier] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'table_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[TableSignedIdentifier]'}, + } + + def __init__( + self, + *, + signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, + **kwargs + ): + """ + :keyword signed_identifiers: List of stored access policies specified on the table. + :paramtype signed_identifiers: + list[~azure.mgmt.storage.v2022_05_01.models.TableSignedIdentifier] + """ + super(Table, self).__init__(**kwargs) + self.table_name = None + self.signed_identifiers = signed_identifiers + + +class TableAccessPolicy(msrest.serialization.Model): + """Table Access Policy Properties Object. + + All required parameters must be populated in order to send to Azure. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: Required. Required. List of abbreviated permissions. Supported permission + values include 'r','a','u','d'. + :vartype permission: str + """ + + _validation = { + 'permission': {'required': True}, + } + + _attribute_map = { + 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, + 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, + 'permission': {'key': 'permission', 'type': 'str'}, + } + + def __init__( + self, + *, + permission: str, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: Required. Required. List of abbreviated permissions. Supported permission + values include 'r','a','u','d'. + :paramtype permission: str + """ + super(TableAccessPolicy, self).__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class TableServiceProperties(Resource): + """The properties of a storage account’s Table service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :vartype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + """ + + _validation = { + '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'}, + 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules + """ + super(TableServiceProperties, self).__init__(**kwargs) + self.cors = cors + + +class TableSignedIdentifier(msrest.serialization.Model): + """Object to set Table Access Policy. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Required. unique-64-character-value of the stored access policy. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2022_05_01.models.TableAccessPolicy + """ + + _validation = { + 'id': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'access_policy': {'key': 'accessPolicy', 'type': 'TableAccessPolicy'}, + } + + def __init__( + self, + *, + id: str, + access_policy: Optional["_models.TableAccessPolicy"] = None, + **kwargs + ): + """ + :keyword id: Required. unique-64-character-value of the stored access policy. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2022_05_01.models.TableAccessPolicy + """ + super(TableSignedIdentifier, self).__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class TagFilter(msrest.serialization.Model): + """Blob index tag based filtering for blob objects. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :vartype name: str + :ivar op: Required. This is the comparison operator which is used for object comparison and + filtering. Only == (equality operator) is currently supported. + :vartype op: str + :ivar value: Required. This is the filter tag value field used for tag based filtering, it can + have 0 - 256 characters. + :vartype value: str + """ + + _validation = { + 'name': {'required': True, 'max_length': 128, 'min_length': 1}, + 'op': {'required': True}, + 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'op': {'key': 'op', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + name: str, + op: str, + value: str, + **kwargs + ): + """ + :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :paramtype name: str + :keyword op: Required. This is the comparison operator which is used for object comparison and + filtering. Only == (equality operator) is currently supported. + :paramtype op: str + :keyword value: Required. This is the filter tag value field used for tag based filtering, it + can have 0 - 256 characters. + :paramtype value: str + """ + super(TagFilter, self).__init__(**kwargs) + self.name = name + self.op = op + self.value = value + + +class TagProperty(msrest.serialization.Model): + """A tag of the LegalHold of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tag: The tag value. + :vartype tag: str + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who added the tag. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who added the tag. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who added the tag. + :vartype upn: str + """ + + _validation = { + 'tag': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'object_identifier': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'upn': {'readonly': True}, + } + + _attribute_map = { + 'tag': {'key': 'tag', 'type': 'str'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'upn': {'key': 'upn', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(TagProperty, self).__init__(**kwargs) + self.tag = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + + +class UpdateHistoryProperty(msrest.serialization.Model): + """An update history of the ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: + put, lock and extend. Known values are: "put", "lock", "extend". + :vartype update: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyUpdateType + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar timestamp: Returns the date and time the ImmutabilityPolicy was updated. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who updated the ImmutabilityPolicy. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who updated the + ImmutabilityPolicy. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who updated the ImmutabilityPolicy. + :vartype upn: str + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + 'update': {'readonly': True}, + 'immutability_period_since_creation_in_days': {'readonly': True}, + 'timestamp': {'readonly': True}, + 'object_identifier': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'upn': {'readonly': True}, + } + + _attribute_map = { + 'update': {'key': 'update', 'type': 'str'}, + 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, + 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'upn': {'key': 'upn', 'type': 'str'}, + 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + } + + def __init__( + self, + *, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super(UpdateHistoryProperty, self).__init__(**kwargs) + self.update = None + self.immutability_period_since_creation_in_days = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class Usage(msrest.serialization.Model): + """Describes Storage Resource Usage. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", + "Percent", "CountsPerSecond", "BytesPerSecond". + :vartype unit: str or ~azure.mgmt.storage.v2022_05_01.models.UsageUnit + :ivar current_value: Gets the current count of the allocated resources in the subscription. + :vartype current_value: int + :ivar limit: Gets the maximum count of the resources that can be allocated in the subscription. + :vartype limit: int + :ivar name: Gets the name of the type of usage. + :vartype name: ~azure.mgmt.storage.v2022_05_01.models.UsageName + """ + + _validation = { + 'unit': {'readonly': True}, + 'current_value': {'readonly': True}, + 'limit': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'unit': {'key': 'unit', 'type': 'str'}, + 'current_value': {'key': 'currentValue', 'type': 'int'}, + 'limit': {'key': 'limit', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'UsageName'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Usage, self).__init__(**kwargs) + self.unit = None + self.current_value = None + self.limit = None + self.name = None + + +class UsageListResult(msrest.serialization.Model): + """The response from the List Usages operation. + + :ivar value: Gets or sets the list of Storage Resource Usages. + :vartype value: list[~azure.mgmt.storage.v2022_05_01.models.Usage] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Usage]'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.Usage"]] = None, + **kwargs + ): + """ + :keyword value: Gets or sets the list of Storage Resource Usages. + :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.Usage] + """ + super(UsageListResult, self).__init__(**kwargs) + self.value = value + + +class UsageName(msrest.serialization.Model): + """The usage names that can be used; currently limited to StorageAccount. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets a string describing the resource name. + :vartype value: str + :ivar localized_value: Gets a localized string describing the resource name. + :vartype localized_value: str + """ + + _validation = { + 'value': {'readonly': True}, + 'localized_value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UsageName, self).__init__(**kwargs) + self.value = None + self.localized_value = None + + +class UserAssignedIdentity(msrest.serialization.Model): + """UserAssignedIdentity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the identity. + :vartype principal_id: str + :ivar client_id: The client ID of the identity. + :vartype client_id: str + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'client_id': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'client_id': {'key': 'clientId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(UserAssignedIdentity, self).__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class VirtualNetworkRule(msrest.serialization.Model): + """Virtual Network rule. + + All required parameters must be populated in order to send to Azure. + + :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + :vartype virtual_network_resource_id: str + :ivar action: The action of virtual network rule. The only acceptable values to pass in are + None and "Allow". The default value is None. + :vartype action: str + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.State + """ + + _validation = { + 'virtual_network_resource_id': {'required': True}, + } + + _attribute_map = { + 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, + 'action': {'key': 'action', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + } + + def __init__( + self, + *, + virtual_network_resource_id: str, + action: Optional[str] = None, + state: Optional[Union[str, "_models.State"]] = None, + **kwargs + ): + """ + :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + :paramtype virtual_network_resource_id: str + :keyword action: The action of virtual network rule. The only acceptable values to pass in are + None and "Allow". The default value is None. + :paramtype action: str + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.State + """ + super(VirtualNetworkRule, self).__init__(**kwargs) + self.virtual_network_resource_id = virtual_network_resource_id + self.action = action + self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py new file mode 100644 index 000000000000..5218134c47f9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py @@ -0,0 +1,549 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Required for storage accounts where kind = BlobStorage. The access tier is used for billing. + The 'Premium' access tier is the default value for premium block blobs storage account type and + it cannot be changed for the premium block blobs storage account type. + """ + + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the + policy, Unlocked state allows increase and decrease of immutability retention time and also + allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of + the immutability retention time. A policy can only be created in a Disabled or Unlocked state + and can be toggled between the two states. Only a policy in an Unlocked state can transition to + a Locked state which cannot be reverted. + """ + + UNLOCKED = "Unlocked" + LOCKED = "Locked" + DISABLED = "Disabled" + +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status indicating whether the primary location of the storage account is available or + unavailable. + """ + + AVAILABLE = "available" + UNAVAILABLE = "unavailable" + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the Active Directory account type for Azure Storage. + """ + + USER = "User" + COMPUTER = "Computer" + +class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the + same VNet. + """ + + PRIVATE_LINK = "PrivateLink" + AAD = "AAD" + +class AllowedMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + DELETE = "DELETE" + GET = "GET" + HEAD = "HEAD" + MERGE = "MERGE" + POST = "POST" + OPTIONS = "OPTIONS" + PUT = "PUT" + PATCH = "PATCH" + +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + DEFAULT = "default" + +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob + restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - + Failed: Indicates that blob restore is failed. + """ + + IN_PROGRESS = "InProgress" + COMPLETE = "Complete" + FAILED = "Failed" + +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are + any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to + bypass none of those traffics. + """ + + NONE = "None" + LOGGING = "Logging" + METRICS = "Metrics" + AZURE_SERVICES = "AzureServices" + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the default action of allow or deny when no other rules match. + """ + + ALLOW = "Allow" + DENY = "Deny" + +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default share permission for users using Kerberos authentication if RBAC role is not assigned. + """ + + NONE = "None" + STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" + STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" + STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the directory service used. Note that this enum may be extended in the future. + """ + + NONE = "None" + AADDS = "AADDS" + AD = "AD" + AADKERB = "AADKERB" + +class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number + of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the + endpoint URL will have an alphanumeric DNS Zone identifier. + """ + + STANDARD = "Standard" + AZURE_DNS_ZONE = "AzureDnsZone" + +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication protocol that is used for the file share. Can only be specified when + creating a share. + """ + + SMB = "SMB" + NFS = "NFS" + +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, + Microsoft.KeyVault. + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SAS expiration action. Can only be Log. + """ + + LOG = "Log" + +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of extendedLocation. + """ + + EDGE_ZONE = "EdgeZone" + +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field, it specifies the format for the inventory files. + """ + + CSV = "Csv" + PARQUET = "Parquet" + +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the secondary location. Possible values are: - Live: Indicates that the secondary + location is active and operational. - Bootstrap: Indicates initial synchronization from the + primary location to the secondary location is in progress.This typically occurs when + replication is first enabled. - Unavailable: Indicates that the secondary location is + temporarily unavailable. + """ + + LIVE = "Live" + BOOTSTRAP = "Bootstrap" + UNAVAILABLE = "Unavailable" + +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The protocol permitted for a request made with the account SAS. + """ + + HTTPS_HTTP = "https,http" + HTTPS = "https" + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. + """ + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and + extend. + """ + + PUT = "put" + LOCK = "lock" + EXTEND = "extend" + +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Inventory + """ + + INVENTORY = "Inventory" + +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Permissions for the key -- read-only or full permissions. + """ + + READ = "Read" + FULL = "Full" + +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, + Microsoft.Keyvault + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encryption key type to be used for the encryption service. 'Account' key type implies that an + account-scoped encryption key will be used. 'Service' key type implies that a default service + key is used. + """ + + SERVICE = "Service" + ACCOUNT = "Account" + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the type of storage account. + """ + + STORAGE = "Storage" + STORAGE_V2 = "StorageV2" + BLOB_STORAGE = "BlobStorage" + FILE_STORAGE = "FileStorage" + BLOCK_BLOB_STORAGE = "BlockBlobStorage" + +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. + """ + + DISABLED = "Disabled" + ENABLED = "Enabled" + +class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions. + """ + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK_ENUM = "Break" + +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether the lease on a container is of infinite or fixed duration, only when the + container is leased. + """ + + INFINITE = "Infinite" + FIXED = "Fixed" + +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions. + """ + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK_ENUM = "Break" + +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Lease state of the container. + """ + + AVAILABLE = "Available" + LEASED = "Leased" + EXPIRED = "Expired" + BREAKING = "Breaking" + BROKEN = "Broken" + +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lease status of the container. + """ + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + DELETED = "deleted" + +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + DEFAULT = "default" + +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property denotes the container level immutability to object level immutability migration + state. + """ + + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Set the minimum TLS version to be permitted on requests to storage. The default interpretation + is TLS 1.0 for this property. + """ + + TLS1_0 = "TLS1_0" + TLS1_1 = "TLS1_1" + TLS1_2 = "TLS1_2" + +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only + """ + + ACCESS_TIME_TRACKING = "AccessTimeTracking" + +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field specifies the scope of the inventory created either at the + blob or container level. + """ + + BLOB = "Blob" + CONTAINER = "Container" + +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), + Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + """ + + R = "r" + D = "d" + W = "w" + L = "l" + A = "a" + C = "c" + U = "u" + P = "p" + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state. + """ + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status. + """ + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the storage account at the time the operation was called. + """ + + CREATING = "Creating" + RESOLVING_DNS = "ResolvingDNS" + SUCCEEDED = "Succeeded" + +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether data in the container may be accessed publicly and the level of access. + """ + + CONTAINER = "Container" + BLOB = "Blob" + NONE = "None" + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow or disallow public network access to Storage Account. Value is optional but if passed in, + must be 'Enabled' or 'Disabled'. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the reason that a storage account name could not be used. The Reason element is only + returned if NameAvailable is false. + """ + + ACCOUNT_NAME_INVALID = "AccountNameInvalid" + ALREADY_EXISTS = "AlreadyExists" + +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The property is for NFS share only. The default is NoRootSquash. + """ + + NO_ROOT_SQUASH = "NoRootSquash" + ROOT_SQUASH = "RootSquash" + ALL_SQUASH = "AllSquash" + +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Routing Choice defines the kind of network routing opted by the user. + """ + + MICROSOFT_ROUTING = "MicrosoftRouting" + INTERNET_ROUTING = "InternetRouting" + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Lifecycle + """ + + LIFECYCLE = "Lifecycle" + +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field is used to schedule an inventory formation. + """ + + DAILY = "Daily" + WEEKLY = "Weekly" + +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue + (q), Table (t), File (f). + """ + + B = "b" + Q = "q" + T = "t" + F = "f" + +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), + Hot, and Cool. FileStorage account can choose Premium. + """ + + TRANSACTION_OPTIMIZED = "TransactionOptimized" + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the service SAS. Possible values include: Blob (b), + Container (c), File (f), Share (s). + """ + + B = "b" + C = "c" + F = "f" + S = "s" + +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed resource types that are accessible with the account SAS. Service (s): Access to + service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to + object-level APIs for blobs, queue messages, table entities, and files. + """ + + S = "s" + C = "c" + O = "o" + +class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property indicates the current sku conversion status. + """ + + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name. Required for account creation; optional for update. Note that in older versions, + SKU name was called accountType. + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_GRS = "Standard_GRS" + STANDARD_RAGRS = "Standard_RAGRS" + STANDARD_ZRS = "Standard_ZRS" + PREMIUM_LRS = "Premium_LRS" + PREMIUM_ZRS = "Premium_ZRS" + STANDARD_GZRS = "Standard_GZRS" + STANDARD_RAGZRS = "Standard_RAGZRS" + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier. This is based on the SKU name. + """ + + STANDARD = "Standard" + PREMIUM = "Premium" + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the state of virtual network rule. + """ + + PROVISIONING = "Provisioning" + DEPROVISIONING = "Deprovisioning" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + GEO_REPLICATION_STATS = "geoReplicationStats" + BLOB_RESTORE_STATUS = "blobRestoreStatus" + +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the unit of measurement. + """ + + COUNT = "Count" + BYTES = "Bytes" + SECONDS = "Seconds" + PERCENT = "Percent" + COUNTS_PER_SECOND = "CountsPerSecond" + BYTES_PER_SECOND = "BytesPerSecond" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py new file mode 100644 index 000000000000..22f9808d440a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py @@ -0,0 +1,56 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'SkusOperations', + 'StorageAccountsOperations', + 'DeletedAccountsOperations', + 'UsagesOperations', + 'ManagementPoliciesOperations', + 'BlobInventoryPoliciesOperations', + 'PrivateEndpointConnectionsOperations', + 'PrivateLinkResourcesOperations', + 'ObjectReplicationPoliciesOperations', + 'LocalUsersOperations', + 'EncryptionScopesOperations', + 'BlobServicesOperations', + 'BlobContainersOperations', + 'FileServicesOperations', + 'FileSharesOperations', + 'QueueServicesOperations', + 'QueueOperations', + 'TableServicesOperations', + 'TableOperations', +] +__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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..acf7df0183fa --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py @@ -0,0 +1,1932 @@ +# 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, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, "_models.ListContainersInclude"]] = 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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if maxpagesize is not None: + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if include is not None: + _params['$include'] = _SERIALIZER.query("include", include, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.BlobContainer] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_update_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.BlobContainer] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_get_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_request( + resource_group_name: str, + account_name: str, + container_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', "2022-05-01")) # type: str + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + **kwargs + ) + + +def build_set_legal_hold_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.LegalHold] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_clear_legal_hold_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.LegalHold] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_create_or_update_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.ImmutabilityPolicy] = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_get_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if if_match is not None: + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_lock_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_extend_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + json: Optional[_models.ImmutabilityPolicy] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_lease_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + json: Optional[_models.LeaseContainerRequest] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_object_level_worm_request_initial( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`blob_containers` 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, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + **kwargs: Any + ) -> Iterable[_models.ListContainerItems]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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("ListContainerItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param blob_container: Properties of the blob container to create. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-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.BlobContainer] + + _json = self._serialize.body(blob_container, 'BlobContainer') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.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) + + if response.status_code == 200: + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param blob_container: Properties to update for the blob container. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-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.BlobContainer] + + _json = self._serialize.body(blob_container, 'BlobContainer') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobContainer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LegalHold, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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-05-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.LegalHold] + + _json = self._serialize.body(legal_hold, 'LegalHold') + + request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.set_legal_hold.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LegalHold', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LegalHold, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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-05-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.LegalHold] + + _json = self._serialize.body(legal_hold, 'LegalHold') + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.clear_legal_hold.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LegalHold', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-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.ImmutabilityPolicy] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + else: + _json = None + + request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace + def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + if_match=if_match, + template_url=self.get_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace + def delete_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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 {}) + + immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + if_match=if_match, + template_url=self.delete_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + + @distributed_trace + def lock_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + + + request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + if_match=if_match, + template_url=self.lock_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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-05-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.ImmutabilityPolicy] + + if parameters is not None: + _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + else: + _json = None + + request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.extend_immutability_policy.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LeaseContainerResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :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-05-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.LeaseContainerResponse] + + if parameters is not None: + _json = self._serialize.body(parameters, 'LeaseContainerRequest') + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore + + + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_object_level_worm_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._object_level_worm_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + + + @distributed_trace + def begin_object_level_worm( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + container_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. + :type container_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-05-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] + if cont_token is None: + raw_result = self._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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, + lro_options={'final-state-via': 'location'}, + + **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_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..f4accbb69fa1 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,522 @@ +# 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 + +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_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + *, + json: Optional[_models.BlobInventoryPolicy] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_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( + resource_group_name: str, + account_name: str, + subscription_id: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + properties: _models.BlobInventoryPolicy, + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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-05-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.BlobInventoryPolicy] + + _json = self._serialize.body(properties, 'BlobInventoryPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + blob_inventory_policy_name=blob_inventory_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.ListBlobInventoryPolicy]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListBlobInventoryPolicy or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListBlobInventoryPolicy] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ListBlobInventoryPolicy", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py new file mode 100644 index 000000000000..3bdc01deb5e0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py @@ -0,0 +1,415 @@ +# 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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_set_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.BlobServiceProperties] = 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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_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_get_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`blob_services` 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, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.BlobServiceItems]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either BlobServiceItems or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("BlobServiceItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # 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.BlobServiceProperties] + + _json = self._serialize.body(parameters, 'BlobServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + + + @distributed_trace + def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :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-05-01")) # type: str + blob_services_name = kwargs.pop('blob_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..a0909a5c3ee0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py @@ -0,0 +1,262 @@ +# 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( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + deleted_account_name: str, + location: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + path_format_arguments = { + "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), + "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`deleted_accounts` 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.DeletedAccountListResult]: + """Lists deleted accounts under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("DeletedAccountListResult", 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.Storage/deletedAccounts"} # type: ignore + + @distributed_trace + def get( + self, + deleted_account_name: str, + location: str, + **kwargs: Any + ) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. + :type deleted_account_name: str + :param location: The location of the deleted storage account. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + + + request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + 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('DeletedAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..a1687ec3ad1a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py @@ -0,0 +1,553 @@ +# 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_put_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + encryption_scope_name: str, + *, + json: Optional[_models.EncryptionScope] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + } + + _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_patch_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + encryption_scope_name: str, + *, + json: Optional[_models.EncryptionScope] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + } + + _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_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + encryption_scope_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + } + + _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_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`encryption_scopes` 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 put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-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.EncryptionScope] + + _json = self._serialize.body(encryption_scope, 'EncryptionScope') + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.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) + + if response.status_code == 200: + deserialized = self._deserialize('EncryptionScope', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-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.EncryptionScope] + + _json = self._serialize.body(encryption_scope, 'EncryptionScope') + + request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.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('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. + :type encryption_scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + encryption_scope_name=encryption_scope_name, + 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('EncryptionScope', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.EncryptionScopeListResult]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EncryptionScopeListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("EncryptionScopeListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py new file mode 100644 index 000000000000..9f80e5b5a54b --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py @@ -0,0 +1,389 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_set_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.FileServiceProperties] = 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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_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_get_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`file_services` 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, + account_name: str, + **kwargs: Any + ) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceItems, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceItems', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # 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.FileServiceProperties] + + _json = self._serialize.body(parameters, 'FileServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + + + @distributed_trace + def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :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-05-01")) # type: str + file_services_name = kwargs.pop('file_services_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py new file mode 100644 index 000000000000..1b1f65da2c3e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py @@ -0,0 +1,995 @@ +# 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, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if maxpagesize is not None: + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + json: Optional[_models.FileShare] = None, + content: Any = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, '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 + ) + + +def build_update_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + json: Optional[_models.FileShare] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_get_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + if x_ms_snapshot is not None: + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if include is not None: + _params['$include'] = _SERIALIZER.query("include", include, 'str') + + # Construct headers + if x_ms_snapshot is not None: + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_restore_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + json: Optional[_models.DeletedShare] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_lease_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + json: Optional[_models.LeaseShareRequest] = None, + content: Any = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if x_ms_snapshot is not None: + _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`file_shares` 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, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.FileShareItems]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FileShareItems or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItems] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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("FileShareItems", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param file_share: Properties of the file share to create. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-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.FileShare] + + _json = self._serialize.body(file_share, 'FileShare') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + expand=expand, + template_url=self.create.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) + + if response.status_code == 200: + deserialized = self._deserialize('FileShare', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param file_share: Properties to update for the file share. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-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.FileShare] + + _json = self._serialize.body(file_share, 'FileShare') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FileShare', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. + :type include: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + x_ms_snapshot=x_ms_snapshot, + include=include, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param deleted_share: + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare + :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-05-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] + + _json = self._serialize.body(deleted_share, 'DeletedShare') + + request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.restore.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LeaseShareResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :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-05-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.LeaseShareResponse] + + if parameters is not None: + _json = self._serialize.body(parameters, 'LeaseShareRequest') + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + x_ms_snapshot=x_ms_snapshot, + template_url=self.lease.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + + deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py new file mode 100644 index 000000000000..0332fdbff4d0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py @@ -0,0 +1,742 @@ +# 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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + username: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + } + + _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, + account_name: str, + subscription_id: str, + username: str, + *, + json: Optional[_models.LocalUser] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + } + + _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, + account_name: str, + subscription_id: str, + username: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + } + + _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, + account_name: str, + subscription_id: str, + username: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + } + + _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_password_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + username: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + } + + _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 LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`local_users` 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, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.LocalUsers]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either LocalUsers or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUsers] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("LocalUsers", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUser', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :param properties: The local user associated with a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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-05-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.LocalUser] + + _json = self._serialize.body(properties, 'LocalUser') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUser', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + + @distributed_trace + def list_keys( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserKeys, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + 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('LocalUserKeys', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore + + + @distributed_trace + def regenerate_password( + self, + resource_group_name: str, + account_name: str, + username: str, + **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + + + request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + username=username, + api_version=api_version, + template_url=self.regenerate_password.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('LocalUserRegeneratePasswordResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py new file mode 100644 index 000000000000..8d9e3779dabb --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py @@ -0,0 +1,383 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar, Union + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + *, + json: Optional[_models.ManagementPolicy] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_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( + resource_group_name: str, + account_name: str, + subscription_id: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + **kwargs + ) + +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`management_policies` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + properties: _models.ManagementPolicy, + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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-05-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.ManagementPolicy] + + _json = self._serialize.body(properties, 'ManagementPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, "_models.ManagementPolicyName"], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + management_policy_name=management_policy_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..02bc9a746798 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py @@ -0,0 +1,529 @@ +# 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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + object_replication_policy_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + } + + _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, + account_name: str, + subscription_id: str, + object_replication_policy_id: str, + *, + json: Optional[_models.ObjectReplicationPolicy] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + } + + _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, + account_name: str, + subscription_id: str, + object_replication_policy_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`object_replication_policies` 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, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.ObjectReplicationPolicies]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ObjectReplicationPolicies or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicies] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ObjectReplicationPolicies", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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('ObjectReplicationPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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-05-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.ObjectReplicationPolicy] + + _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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('ObjectReplicationPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. + :type object_replication_policy_id: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + object_replication_policy_id=object_replication_policy_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.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py new file mode 100644 index 000000000000..fe55857344f0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py @@ -0,0 +1,151 @@ +# 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 +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable[_models.OperationListResult]: + """Lists all of the available Storage 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.storage.v2022_05_01.models.OperationListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + 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( + 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("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# 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/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..320e7da285c7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,521 @@ +# 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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + account_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_put_request( + resource_group_name: str, + account_name: str, + subscription_id: 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "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( + resource_group_name: str, + account_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'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, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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.storage.v2022_05_01.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-05-01")) # 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, + account_name=account_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, + account_name=account_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 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :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.storage.v2022_05_01.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. + :type properties: ~azure.mgmt.storage.v2022_05_01.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.storage.v2022_05_01.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-05-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] + + _json = self._serialize.body(properties, 'PrivateEndpointConnection') + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.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 + + put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. + :type private_endpoint_connection_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + private_endpoint_connection_name=private_endpoint_connection_name, + 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.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..1ca28aad1028 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py @@ -0,0 +1,149 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._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_storage_account_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`private_link_resources` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list_by_storage_account( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResourceListResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + + + request = build_list_by_storage_account_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_storage_account.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py new file mode 100644 index 000000000000..e90c04972d86 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py @@ -0,0 +1,668 @@ +# 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_create_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + queue_name: str, + *, + json: Optional[_models.StorageQueue] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + } + + _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_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + queue_name: str, + *, + json: Optional[_models.StorageQueue] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + } + + _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_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + queue_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + } + + _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_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + queue_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + } + + _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_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if maxpagesize is not None: + _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + if filter is not None: + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`queue` 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 create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-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.StorageQueue] + + _json = self._serialize.body(queue, 'StorageQueue') + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-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.StorageQueue] + + _json = self._serialize.body(queue, 'StorageQueue') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + **kwargs: Any + ) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageQueue', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + queue_name: str, + **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + queue_name=queue_name, + 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 [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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable[_models.ListQueueResource]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListQueueResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueueResource] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + 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, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + maxpagesize=maxpagesize, + filter=filter, + 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("ListQueueResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py new file mode 100644 index 000000000000..418b7ab2de5e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py @@ -0,0 +1,389 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_set_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.QueueServiceProperties] = 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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_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_get_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`queue_services` 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, + account_name: str, + **kwargs: Any + ) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListQueueServices, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListQueueServices', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # 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.QueueServiceProperties] + + _json = self._serialize.body(parameters, 'QueueServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + + + @distributed_trace + def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :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-05-01")) # type: str + queue_service_name = kwargs.pop('queue_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py new file mode 100644 index 000000000000..d88cb1250174 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py @@ -0,0 +1,160 @@ +# 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( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`skus` 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.StorageSkuListResult]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageSkuListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageSkuListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageSkuListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..8598fd015c21 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py @@ -0,0 +1,2152 @@ +# 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_check_name_availability_request( + subscription_id: str, + *, + json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_create_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.StorageAccountCreateParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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, + account_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', "2022-05-01")) # type: str + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + **kwargs + ) + + +def build_get_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, "_models.StorageAccountExpand"]] = 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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, '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, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.StorageAccountUpdateParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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, + account_name: str, + subscription_id: str, + *, + expand: Optional[str] = "kerb", + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_regenerate_key_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.StorageAccountRegenerateKeyParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_account_sas_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.AccountSasParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_service_sas_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.ServiceSasParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_failover_request_initial( + resource_group_name: str, + account_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', "2022-05-01")) # type: str + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/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, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + **kwargs + ) + + +def build_hierarchical_namespace_migration_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + request_type: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_abort_hierarchical_namespace_migration_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_restore_blob_ranges_request_initial( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.BlobRestoreParameters] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_revoke_user_delegation_keys_request( + resource_group_name: str, + account_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', "2022-05-01")) # type: str + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_params, + **kwargs + ) + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`storage_accounts` 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 check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2022_05_01.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-05-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] + + _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + + 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) + raise HttpResponseError(response=response, 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.Storage/checkNameAvailability"} # type: ignore + + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + 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-05-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.StorageAccount]] + + _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + + request = build_create_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the created account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :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-05-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.StorageAccount] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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('StorageAccount', 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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace + def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Default value is None. + :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + + + request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + template_url=self.get_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for the updated account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :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-05-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.StorageAccount] + + _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccount', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable[_models.StorageAccountListResult]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable[_models.StorageAccountListResult]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :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 StorageAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + + error_map = { + 401: ClientAuthenticationError, 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("StorageAccountListResult", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_keys( + self, + resource_group_name: str, + account_name: str, + expand: Optional[str] = "kerb", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" or None. Default value is "kerb". + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + expand=expand, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. + :type regenerate_key: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :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-05-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.StorageAccountListKeysResult] + + _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.regenerate_key.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListAccountSasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :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-05-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.ListAccountSasResponse] + + _json = self._serialize.body(parameters, 'AccountSasParameters') + + request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_account_sas.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListServiceSasResponse, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :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-05-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.ListServiceSasResponse] + + _json = self._serialize.body(parameters, 'ServiceSasParameters') + + request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.list_service_sas.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore + + + def _failover_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_failover_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._failover_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + + @distributed_trace + def begin_failover( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Failover request can be triggered for a storage account in case of availability issues. The + failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS + accounts. The secondary cluster will become primary after failover. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-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] + if cont_token is None: + raw_result = self._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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, + lro_options={'final-state-via': 'location'}, + + **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_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + request_type: 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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_hierarchical_namespace_migration_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + request_type=request_type, + template_url=self._hierarchical_namespace_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, 202]: + 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, {}) + + _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + + @distributed_trace + def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + request_type: str, + **kwargs: Any + ) -> LROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. + :type request_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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-05-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] + if cont_token is None: + raw_result = self._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + 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, + lro_options={'final-state-via': 'location'}, + + **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_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_abort_hierarchical_namespace_migration_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._abort_hierarchical_namespace_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, 202]: + 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, {}) + + _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + + @distributed_trace + def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-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] + if cont_token is None: + raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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, + lro_options={'final-state-via': 'location'}, + + **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_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + **kwargs: Any + ) -> _models.BlobRestoreStatus: + 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-05-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.BlobRestoreStatus] + + _json = self._serialize.body(parameters, 'BlobRestoreParameters') + + request = build_restore_blob_ranges_request_initial( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._restore_blob_ranges_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :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-05-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.BlobRestoreStatus] + 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._restore_blob_ranges_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_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('BlobRestoreStatus', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **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_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @distributed_trace + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_revoke_user_delegation_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.revoke_user_delegation_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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py new file mode 100644 index 000000000000..95bed59d76b6 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py @@ -0,0 +1,651 @@ +# 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_create_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + table_name: str, + *, + json: Optional[_models.Table] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + } + + _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_update_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + table_name: str, + *, + json: Optional[_models.Table] = 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-05-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + } + + _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_get_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + table_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + } + + _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_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + table_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + } + + _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_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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 TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`table` 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 create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-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.Table] + + if parameters is not None: + _json = self._serialize.body(parameters, 'Table') + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-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.Table] + + if parameters is not None: + _json = self._serialize.body(parameters, 'Table') + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Table', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + table_name: str, + **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. + :type table_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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + table_name=table_name, + 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 [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.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> Iterable[_models.ListTableResource]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListTableResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListTableResource] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + + error_map = { + 401: ClientAuthenticationError, 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, + account_name=account_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, + account_name=account_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("ListTableResource", 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py new file mode 100644 index 000000000000..73092bc90db8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py @@ -0,0 +1,389 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._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, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _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_set_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + json: Optional[_models.TableServiceProperties] = 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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_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_get_service_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`table_services` 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, + account_name: str, + **kwargs: Any + ) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListTableServices, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices + :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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + + + request = build_list_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ListTableServices', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # 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.TableServiceProperties] + + _json = self._serialize.body(parameters, 'TableServiceProperties') + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + template_url=self.set_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TableServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + + + @distributed_trace + def get_service_properties( + self, + resource_group_name: str, + account_name: str, + **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. + :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties, or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :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-05-01")) # type: str + table_service_name = kwargs.pop('table_service_name', "default") # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + template_url=self.get_service_properties.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('TableServiceProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py new file mode 100644 index 000000000000..e33a12d40885 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py @@ -0,0 +1,166 @@ +# 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_location_request( + subscription_id: str, + location: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_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-05-01")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "location": _SERIALIZER.url("location", location, '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 UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_05_01.StorageManagementClient`'s + :attr:`usages` 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_location( + self, + location: str, + **kwargs: Any + ) -> Iterable[_models.UsageListResult]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either UsageListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.UsageListResult] + :raises: ~azure.core.exceptions.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-05-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + + error_map = { + 401: ClientAuthenticationError, 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_location_request( + subscription_id=self._config.subscription_id, + location=location, + api_version=api_version, + template_url=self.list_by_location.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_location_request( + subscription_id=self._config.subscription_id, + location=location, + 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("UsageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/py.typed b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/setup.py b/sdk/storage/azure-mgmt-storage/setup.py index 76440dd39e86..4d332b7d731d 100644 --- a/sdk/storage/azure-mgmt-storage/setup.py +++ b/sdk/storage/azure-mgmt-storage/setup.py @@ -51,7 +51,6 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', @@ -65,10 +64,14 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + 'azure-mgmt-core>=1.3.1,<2.0.0', ], - python_requires=">=3.6" + python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index d5bd7918f692..805e1f2c13fc 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -339,7 +339,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-iotcentral azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-redisenterprise msrest>=0.6.21 #override azure-mgmt-redisenterprise azure-mgmt-core>=1.3.0,<2.0.0 -#override azure-mgmt-storage azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-storage azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-botservice azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-dashboard msrest>=0.6.21 #override azure-mgmt-dashboard azure-mgmt-core>=1.3.0,<2.0.0